Request | % of cumulative time | Hits | Mean time (ms) | Max time (ms) | Standard deviation | % of cumulative cpu time | Mean cpu time (ms) | Mean allocated Kb | % of system error | Mean size (Kb) | Mean hits sql | Mean time sql (ms) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
http global | 100 | 61,699 | 54 | 241,399 | 1,405 | 100 | 2 | 1,336 | 0.06 | 2 | 1 | 41 |
http warning | 28 | 613 | 1,571 | 241,399 | 10,719 | 3 | 11 | 4,968 | 0.65 | 54 | 2 | 1,482 |
http severe | 21 | 112 | 6,383 | 160,716 | 19,671 | 3 | 48 | 10,211 | 0.00 | 29 | 84 | 3,335 |
Request | % of cumulative time | Hits | Mean time (ms) | Max time (ms) | Standard deviation | % of system error |
---|---|---|---|---|---|---|
sql global | 100 | 79,185 | 34 | 241,123 | 1,087 | 0.00 |
sql warning | 1 | 24 | 1,603 | 12,326 | 3,391 | 0.00 |
sql severe | 37 | 225 | 4,518 | 241,123 | 19,601 | 0.00 |
Request | % of cumulative time | Hits | Mean time (ms) | Max time (ms) | Standard deviation | % of system error |
---|---|---|---|---|---|---|
![]() | 15 | 165 | 2,565 | 241,123 | 19,026 | 0.00 |
![]() | 11 | 42,174 | 7 | 255 | 9 | 0.00 |
![]() | 9 | 280 | 885 | 8,077 | 787 | 0.00 |
![]() | 6 | 11,124 | 15 | 543 | 15 | 0.00 |
![]() | 5 | 2,426 | 63 | 1,046 | 35 | 0.00 |
![]() | 4 | 157 | 836 | 10,915 | 2,450 | 0.00 |
![]() | 4 | 2 | 62,244 | 123,021 | 85,951 | 0.00 |
![]() | 4 | 7 | 17,362 | 59,733 | 20,511 | 0.00 |
![]() | 4 | 8 | 13,966 | 47,665 | 21,047 | 0.00 |
![]() | 3 | 16 | 5,510 | 33,736 | 9,993 | 0.00 |
![]() | 3 | 945 | 92 | 3,845 | 326 | 0.00 |
![]() | 2 | 141 | 571 | 8,559 | 1,465 | 0.00 |
![]() | 2 | 2 | 40,289 | 42,906 | 3,700 | 0.00 |
![]() | 2 | 620 | 124 | 3,176 | 327 | 0.00 |
![]() | 1 | 63 | 651 | 15,174 | 2,352 | 0.00 |
![]() | 1 | 16 | 2,494 | 13,458 | 4,322 | 0.00 |
![]() | 1 | 109 | 265 | 6,804 | 746 | 0.00 |
![]() | 0 | 17 | 1,601 | 12,326 | 3,887 | 0.00 |
![]() | 0 | 36 | 534 | 6,468 | 1,330 | 0.00 |
![]() | 0 | 3,540 | 5 | 252 | 4 | 0.00 |
![]() | 0 | 2,569 | 6 | 220 | 6 | 0.00 |
![]() | 0 | 146 | 110 | 5,678 | 529 | 0.00 |
![]() | 0 | 61 | 223 | 9,700 | 1,233 | 0.00 |
![]() | 0 | 31 | 376 | 4,064 | 961 | 0.00 |
![]() | 0 | 1,190 | 9 | 116 | 8 | 0.00 |
![]() | 0 | 16 | 699 | 8,447 | 2,100 | 0.00 |
![]() | 0 | 9 | 1,005 | 2,374 | 928 | 0.00 |
![]() | 0 | 3 | 2,738 | 7,996 | 4,553 | 0.00 |
![]() | 0 | 604 | 12 | 100 | 14 | 0.00 |
![]() | 0 | 2,426 | 2 | 38 | 2 | 0.00 |
![]() | 0 | 5 | 1,400 | 3,498 | 1,866 | 0.00 |
![]() | 0 | 142 | 49 | 1,496 | 192 | 0.00 |
![]() | 0 | 2 | 3,429 | 6,797 | 4,762 | 0.00 |
![]() | 0 | 31 | 210 | 2,003 | 464 | 0.00 |
![]() | 0 | 30 | 212 | 1,367 | 403 | 0.00 |
![]() | 0 | 216 | 27 | 103 | 12 | 0.00 |
![]() | 0 | 9 | 578 | 1,512 | 448 | 0.00 |
![]() | 0 | 327 | 15 | 90 | 10 | 0.00 |
![]() | 0 | 10 | 512 | 1,211 | 578 | 0.00 |
![]() | 0 | 7 | 718 | 1,683 | 631 | 0.00 |
![]() | 0 | 96 | 51 | 246 | 35 | 0.00 |
![]() | 0 | 61 | 79 | 741 | 86 | 0.00 |
![]() | 0 | 61 | 70 | 351 | 36 | 0.00 |
![]() | 0 | 173 | 24 | 431 | 53 | 0.00 |
![]() | 0 | 61 | 70 | 111 | 5 | 0.00 |
![]() ![]() select documentnf0_.cnpj_issuer as cnpj_iss1_14_, documentnf0_.type as type2_14_, documentnf0_.key as key3_14_, documentnf0_.nsu as nsu4_14_, documentnf0_.protocol as protocol5_14_, documentnf0_.addressee_name as addresse6_14_, documentnf0_.available_at as availabl7_14_, documentnf0_.canceled_at as canceled8_14_, documentnf0_.carta_correcao as carta_co9_14_, documentnf0_.cce_events as cce_eve10_14_, documentnf0_.cfops as cfops11_14_, documentnf0_.cnpj as cnpj12_14_, documentnf0_.cnpj_addressee as cnpj_ad13_14_, documentnf0_.cnpj_carrier as cnpj_ca14_14_, documentnf0_.data as data15_14_, documentnf0_.data_emissao as data_em16_14_, documentnf0_.duplicatas as duplica17_14_, documentnf0_.etiquetas as etiquet18_14_, documentnf0_.fatura as fatura19_14_, documentnf0_.issuer_name as issuer_20_14_, documentnf0_.manifestation as manifes21_14_, documentnf0_.name_file as name_fi22_14_, documentnf0_.nfe_number as nfe_num23_14_, documentnf0_.notas_referencia as notas_r24_14_, documentnf0_.status as status25_14_, documentnf0_.value as value26_14_ from public.document_nfe_view documentnf0_ where documentnf0_.data_emissao<=? and documentnf0_.data_emissao>=? and (documentnf0_.key in (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?)) and (documentnf0_.type in (? , ? , ?)) and documentnf0_.cnpj_addressee=? order by documentnf0_.data_emissao desc limit ? | 0 | 2 | 2,127 | 4,131 | 2,833 | 0.00 |
![]() | 0 | 1,830 | 2 | 82 | 2 | 0.00 |
![]() | 0 | 55 | 76 | 181 | 40 | 0.00 |
![]() | 0 | 35 | 117 | 179 | 39 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(item.produto -> 'prod' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.key as key, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'xprod' as descricaoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) as valorProduto, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) as valorBaseCalculoPisCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as somatorioAliquotaPisCofins, ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) as valorRecolhidoPis, ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) as valorRecolhidoCofins, ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as valorTotalRecolhidoPisCofins, ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) as valorPisAposExclusao, ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) as valorCofinsAposExclusao, ( ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) + ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) ) as pisRecuperarAntesRevisao, ( ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) ) + ( ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) ) as valorTotalRecuperarAntesRevisao, ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 as pisGroussUp, ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 as cofinsGroussUp, ( ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) + ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) + ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) - ( ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) + ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type , jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') AND CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 AND CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND item.produto -> 'prod' ->> 'cfop' IN ( '5101', '5102', '5103', '5104', '5105', '5106', '5109', '5110', '5111', '5112', '5113', '5114', '5115', '5116', '5117', '5118', '5119', '5120', '5122', '5123', '5124', '5125', '5251', '5252', '5253', '5254', '5255', '5256', '5257', '5258', '5301', '5302', '5303', '5304', '5305', '5306', '5307', '5351', '5352', '5353', '5354', '5355', '5356', '5357', '5359', '5360', '5401', '5402', '5403', '5405', '5501', '5502', '5651', '5652', '5653', '5654', '5655', '5656', '5667', '5932', '6101', '6102', '6103', '6104', '6105', '6106', '6107', '6108', '6109', '6110', '6111', '6112', '6113', '6114', '6115', '6116', '6117', '6118', '6119', '6120', '6122', '6123', '6124', '6125', '6251', '6252', '6253', '6254', '6255', '6256', '6257', '6258', '6301', '6302', '6303', '6304', '6305', '6306', '6307', '6351', '6352', '6353', '6354', '6355', '6356', '6357', '6359', '6360', '6401', '6402', '6403', '6404', '6501', '6502', '6651', '6652', '6653', '6654', '6655', '6656', '6667', '6932', '7101', '7102', '7105', '7106', '7127', '7251', '7301', '7358', '7501', '7651', '7654', '7667' ) AND ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) >= CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') AS NUMERIC) ) AND ( ( ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) + ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) - ( ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) + ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( ( 100 - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) ) ) / 100 ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) ) > 0 ORDER BY key, codigoProduto limit ? | 0 | 61 | 65 | 73 | 3 | 0.00 |
![]() | 0 | 1 | 3,846 | 3,846 | 0 | 0.00 |
![]() | 0 | 305 | 11 | 80 | 8 | 0.00 |
![]() | 0 | 63 | 52 | 1,132 | 158 | 0.00 |
![]() ![]() select documentnf0_.cnpj_issuer as cnpj_iss1_12_, documentnf0_.type as type2_12_, documentnf0_.key as key3_12_, documentnf0_.nsu as nsu4_12_, documentnf0_.protocol as protocol5_12_, documentnf0_.addressee_name as addresse6_12_, documentnf0_.available_at as availabl7_12_, documentnf0_.canceled_at as canceled8_12_, documentnf0_.canhoto_associado_at as canhoto_9_12_, documentnf0_.canhoto_diferenca_dias_associacao as canhoto10_12_, documentnf0_.canhoto_id as canhoto11_12_, documentnf0_.canhoto_numero_nota as canhoto12_12_, documentnf0_.carta_correcao as carta_c13_12_, documentnf0_.cce_events as cce_eve14_12_, documentnf0_.cfops as cfops15_12_, documentnf0_.cnpj as cnpj16_12_, documentnf0_.cnpj_addressee as cnpj_ad17_12_, documentnf0_.cnpj_carrier as cnpj_ca18_12_, documentnf0_.data as data19_12_, documentnf0_.data_emissao as data_em20_12_, documentnf0_.duplicatas as duplica21_12_, documentnf0_.etiquetas as etiquet22_12_, documentnf0_.fatura as fatura23_12_, documentnf0_.issuer_name as issuer_24_12_, documentnf0_.manifestation as manifes25_12_, documentnf0_.name_file as name_fi26_12_, documentnf0_.nfe_number as nfe_num27_12_, documentnf0_.notas_referencia as notas_r28_12_, documentnf0_.status as status29_12_, documentnf0_.value as value30_12_ from public.document_nfe_canhoto_view documentnf0_ where documentnf0_.data_emissao<=? and documentnf0_.data_emissao>=? and (documentnf0_.key in (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?)) and (documentnf0_.type in (? , ? , ?)) and documentnf0_.cnpj_issuer=? order by documentnf0_.data_emissao desc limit ? | 0 | 1 | 3,194 | 3,194 | 0 | 0.00 |
![]() | 0 | 1,142 | 2 | 25 | 1 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpjEmitente, to_char(d.data_emissao, 'YYYY-MM') as periodo, d.data_emissao as dataEmissao, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.key as chaveDocumento, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' as numeric) as valorProduto, CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) as valorIcmsDifal, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) as antigaBaseCalculoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) as antigaBaseCalculoCofins, CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) as novaBaseCalculoPisCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) as antigoValorPis, ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) as novoValorPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) as antigoValorCofins, ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) as novoValorCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) as valorRecuperacaoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) as valorRecuperacaoCofins, ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as valorRecuperarPisCofins FROM document d inner join document_status ds ON d.key = ds.key, jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE d.cnpj_issuer = ? AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') AND CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'picmsInterPart' as NUMERIC) > 0 AND ds.status = '1' AND item.produto -> 'prod' ->> 'cfop' in ( '6101','6102','6103','6104','6105','6106','6107','6108','6109','6110','6111','6112','6113','6114','6115','6116','6117','6118','6119','6120','6122','6123','6124','6125','6251', '6252','6253','6254','6255','6256','6257','6258','6301','6302','6303','6304','6305','6306','6307','6351','6352','6353','6354','6355','6356','6357','6359','6360','6401','6402','6403','6404','6414','6415','6501','6502','6554','6651','6652','6653','6654','6655','6656','6657','6663','6666','6667','6901','6904','6905','6908','6910','6911','6912','6914','6915','6917','6920','6923','6924','6932' ) AND CAST( COALESCE( item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' ) AS numeric ) > 0 AND CAST( COALESCE( item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' ) AS numeric ) = CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vbcufDest' as numeric) AND ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vicmsufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) > 0 ORDER BY d.data_emissao limit ? | 0 | 61 | 45 | 50 | 2 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpjEmitente, to_char(d.data_emissao, 'YYYY-MM') as periodo, d.data_emissao as dataEmissao, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.key as chaveDocumento, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' as numeric) as valorProduto, CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) as valorIcmsDifal, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) as antigaBaseCalculoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) as antigaBaseCalculoCofins, CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) as novaBaseCalculoPisCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) as antigoValorPis, ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) as novoValorPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) as antigoValorCofins, ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) as novoValorCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) as valorRecuperacaoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) as valorRecuperacaoCofins, ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as valorRecuperarPisCofins FROM document d inner join document_status ds ON d.key = ds.key, jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE d.cnpj_issuer = ? AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') AND CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as NUMERIC) > 0 AND ds.status = '1' AND item.produto -> 'prod' ->> 'cfop' in ( '6101','6102','6103','6104','6105','6106','6107','6108','6109','6110','6111','6112','6113','6114','6115','6116','6117','6118','6119','6120','6122','6123','6124','6125','6251', '6252','6253','6254','6255','6256','6257','6258','6301','6302','6303','6304','6305','6306','6307','6351','6352','6353','6354','6355','6356','6357','6359','6360','6401','6402','6403','6404','6414','6415','6501','6502','6554','6651','6652','6653','6654','6655','6656','6657','6663','6666','6667','6901','6904','6905','6908','6910','6911','6912','6914','6915','6917','6920','6923','6924','6932' ) AND CAST( COALESCE( item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' ) AS numeric ) > 0 AND CAST( COALESCE( item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' ) AS numeric ) = CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vbcufDest' as numeric) AND ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icmsUfDest' ->> 'vfcpufDest' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) > 0 ORDER BY d.data_emissao limit ? | 0 | 61 | 45 | 64 | 3 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpjEmitente, to_char(d.data_emissao, 'YYYY-MM') as periodo, d.data_emissao as dataEmissao, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.key as chaveDocumento, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' as numeric) as valorProduto, CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms' as numeric) aliquotaIcms, CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) valorIcms, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) as antigaBaseCalculoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) as antigaBaseCalculoCofins, CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) as novaBaseCalculoPisCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) as antigoValorPis, ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) as novoValorPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) as antigoValorCofins, ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) as novoValorCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) as valorRecuperacaoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) as valorRecuperacaoCofins, ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as valorRecuperarPisCofins FROM document d inner join document_status ds ON d.key = ds.key, jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE d.cnpj_issuer = ? AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') AND ds.status = '1' AND item.produto -> 'prod' ->> 'cfop' in ( '6101','6102','6103','6104','6105','6106','6107','6108','6109','6110','6111','6112','6113','6114','6115','6116','6117','6118','6119','6120','6122','6123','6124','6125','6251', '6252','6253','6254','6255','6256','6257','6258','6301','6302','6303','6304','6305','6306','6307','6351','6352','6353','6354','6355','6356','6357','6359','6360','6401','6402','6403','6404','6414','6415','6501','6502','6554','6651','6652','6653','6654','6655','6656','6657','6663','6666','6667','6901','6904','6905','6908','6910','6911','6912','6914','6915','6917','6920','6923','6924','6932' ) AND CAST( COALESCE( item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' ) AS numeric ) > CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc' as numeric) AND ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' as numeric) - CAST(item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms' as numeric) ) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) > 0 ORDER BY d.data_emissao limit ? | 0 | 61 | 45 | 62 | 4 | 0.00 |
![]() | 0 | 61 | 41 | 192 | 19 | 0.00 |
![]() | 0 | 5 | 493 | 1,876 | 799 | 0.00 |
![]() | 0 | 93 | 26 | 722 | 78 | 0.00 |
![]() | 0 | 1 | 2,450 | 2,450 | 0 | 0.00 |
![]() | 0 | 3 | 815 | 1,732 | 833 | 0.00 |
![]() | 0 | 1 | 2,388 | 2,388 | 0 | 0.00 |
![]() | 0 | 61 | 38 | 42 | 2 | 0.00 |
![]() | 0 | 5 | 444 | 945 | 440 | 0.00 |
![]() | 0 | 8 | 265 | 771 | 278 | 0.00 |
![]() | 0 | 7 | 278 | 662 | 251 | 0.00 |
![]() | 0 | 3 | 637 | 1,791 | 999 | 0.00 |
![]() | 0 | 2 | 926 | 1,848 | 1,303 | 0.00 |
![]() | 0 | 112 | 16 | 202 | 28 | 0.00 |
![]() | 0 | 61 | 28 | 349 | 43 | 0.00 |
![]() ![]() SELECT d.cnpj_addressee AS cnpjDestinatario, d.data_emissao AS dataEmissao, d.KEY AS chave, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' AS numeroNotaFiscal, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' AS serie, item.produto -> 'prod' ->> 'cprod' AS codigoProduto, item.produto -> 'prod' ->> 'xprod' AS descricaoProduto, item.produto -> 'prod' ->> 'cfop' AS cfop, taxa_selic_acumulada(to_char(date(data_emissao), 'yyyy-MM')) AS taxaSelicAcumulada, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) AS valorProduto, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) AS baseCalculoIpi, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) AS aliquotaIpi, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) AS ipiAntesExclusao, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS numeric) AS baseCalculoPis, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS numeric) AS valorPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS numeric) AS baseCalculoCofins, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS numeric) AS valorCofins, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS numeric) - CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS numeric) as novaBaseCalculo, (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS numeric) - CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS numeric)) * (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) / 100) as ipiDepoisExclusao, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) - ((CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS numeric) - CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS numeric)) * (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) / 100)) diferencaIpi, ((CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) - ((CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS numeric) - CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS numeric)) * (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) / 100)) ) * (taxa_selic_acumulada(to_char(date(data_emissao), 'yyyy-MM')) / 100) ) + (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) - ((CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS numeric) - CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS numeric)) * (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) / 100))) as valorCorrigido FROM document d, jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') AND d.cnpj_addressee = ? AND d.data_emissao BETWEEN cast(? as timestamptz) and cast(? as timestamptz) AND d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'tpNF' = '1' AND item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' = item.produto -> 'prod' ->> 'vprod' AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' as numeric) > 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' as numeric) > 0 AND CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) > 0 AND item.produto -> 'prod' ->> 'cfop' IN ( '5101', '5102', '5103', '5104', '5105', '5106', '5109', '5110', '5111', '5112', '5113', '5114', '5115', '5116', '5117', '5118', '5119', '5120', '5122', '5123', '5124', '5125', '5251', '5252', '5253', '5254', '5255', '5256', '5257', '5258', '5301', '5302', '5303', '5304', '5305', '5306', '5307', '5351', '5352', '5353', '5354', '5355', '5356', '5357', '5359', '5360', '5401', '5402', '5403', '5405', '5414', '5415', '5451', '5501', '5502', '5554', '5651', '5652', '5653', '5654', '5655', '5656', '5657', '5663', '5666', '5667', '5901', '5904', '5905', '5908', '5910', '5911', '5912', '5914', '5915', '5917', '5920', '5923', '5924', '5932', '6101', '6102', '6103', '6104', '6105', '6106', '6107', '6108', '6109', '6110', '6111', '6112', '6113', '6114', '6115', '6116', '6117', '6118', '6119', '6120', '6122', '6123', '6124', '6125', '6251', '6252', '6253', '6254', '6255', '6256', '6257', '6258', '6301', '6302', '6303', '6304', '6305', '6306', '6307', '6351', '6352', '6353', '6354', '6355', '6356', '6357', '6359', '6360', '6401', '6402', '6403', '6404', '6414', '6415', '6501', '6502', '6554', '6651', '6652', '6653', '6654', '6655', '6656', '6657', '6663', '6666', '6667', '6901', '6904', '6905', '6908', '6910', '6911', '6912', '6914', '6915', '6917', '6920', '6923', '6924', '6932', '7101', '7102', '7105', '7106', '7127', '7251', '7301', '7358', '7501', '7651', '7654', '7667', '1201', '1202', '1203', '1204', '1205', '1206', '1207', '1410', '1411', '1503', '1504', '1660', '1661', '1662', '2201', '2202', '2203', '2204', '2205', '2206', '2207', '2410', '2411', '2503', '2504', '2660', '2661', '2662', '3201', '3202', '3205', '3206', '3207', '3211', '3503' ) limit ? | 0 | 61 | 27 | 29 | 0 | 0.00 |
![]() ![]() SELECT d.cnpj_addressee AS cnpj, d.data_emissao AS dataEmissao, d.KEY AS chave, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' AS numeroNotaFiscal, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' AS serie, item.produto -> 'prod' ->> 'cprod' AS codigoProduto, item.produto -> 'prod' ->> 'xprod' AS descricaoProduto, item.produto -> 'prod' ->> 'cfop' AS cfop, taxa_selic_acumulada(to_char(date(data_emissao), 'yyyy-MM')) AS taxaSelicAcumulada, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) AS valorProduto, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) AS baseCalculoIpi, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) AS aliquotaIpi, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) AS valorIpi, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) AS baseCalculoIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as novaBaseCalculoIpi, ( CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric)) * (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) / 100) as ipiDepoisExclusao, CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) - (( CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric)) * (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) / 100)) as diferencaIpi, ((CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) - (( CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric)) * (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) / 100))) * (taxa_selic_acumulada(to_char(date(data_emissao), 'yyyy-MM')) / 100)) + ((CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) - (( CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric)) * (CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'pipi' AS NUMERIC) / 100)))) as valorCorrigido FROM document d, jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') AND d.cnpj_addressee = ? AND d.data_emissao BETWEEN CAST(? AS timestamptz) and CAST(? AS timestamptz) AND d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'tpNF' = '1' AND item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' = COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') AND item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vbc' = item.produto -> 'prod' ->> 'vprod' AND CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms', '0') as numeric) > 0 AND CAST(item.produto -> 'imposto' -> 'ipi' -> 'ipiTrib' ->> 'vipi' AS NUMERIC) > 0 AND item.produto -> 'prod' ->> 'cfop' IN ( '5101', '5102', '5103', '5104', '5105', '5106', '5109', '5110', '5111', '5112', '5113', '5114', '5115', '5116', '5117', '5118', '5119', '5120', '5122', '5123', '5124', '5125', '5251', '5252', '5253', '5254', '5255', '5256', '5257', '5258', '5301', '5302', '5303', '5304', '5305', '5306', '5307', '5351', '5352', '5353', '5354', '5355', '5356', '5357', '5359', '5360', '5401', '5402', '5403', '5405', '5414', '5415', '5451', '5501', '5502', '5554', '5651', '5652', '5653', '5654', '5655', '5656', '5657', '5663', '5666', '5667', '5901', '5904', '5905', '5908', '5910', '5911', '5912', '5914', '5915', '5917', '5920', '5923', '5924', '5932', '6101', '6102', '6103', '6104', '6105', '6106', '6107', '6108', '6109', '6110', '6111', '6112', '6113', '6114', '6115', '6116', '6117', '6118', '6119', '6120', '6122', '6123', '6124', '6125', '6251', '6252', '6253', '6254', '6255', '6256', '6257', '6258', '6301', '6302', '6303', '6304', '6305', '6306', '6307', '6351', '6352', '6353', '6354', '6355', '6356', '6357', '6359', '6360', '6401', '6402', '6403', '6404', '6414', '6415', '6501', '6502', '6554', '6651', '6652', '6653', '6654', '6655', '6656', '6657', '6663', '6666', '6667', '6901', '6904', '6905', '6908', '6910', '6911', '6912', '6914', '6915', '6917', '6920', '6923', '6924', '6932', '7101', '7102', '7105', '7106', '7127', '7251', '7301', '7358', '7501', '7651', '7654', '7667', '1201', '1202', '1203', '1204', '1205', '1206', '1207', '1410', '1411', '1503', '1504', '1660', '1661', '1662', '2201', '2202', '2203', '2204', '2205', '2206', '2207', '2410', '2411', '2503', '2504', '2660', '2661', '2662', '3201', '3202', '3205', '3206', '3207', '3211', '3503' ) limit ? | 0 | 61 | 27 | 30 | 0 | 0.00 |
![]() | 0 | 11 | 149 | 623 | 217 | 0.00 |
![]() | 0 | 22 | 73 | 236 | 84 | 0.00 |
![]() | 0 | 10 | 149 | 1,191 | 366 | 0.00 |
![]() | 0 | 22 | 67 | 719 | 149 | 0.00 |
![]() | 0 | 8 | 169 | 321 | 108 | 0.00 |
![]() | 0 | 324 | 4 | 50 | 6 | 0.00 |
![]() | 0 | 7 | 182 | 508 | 144 | 0.00 |
![]() | 0 | 3 | 423 | 520 | 165 | 0.00 |
![]() | 0 | 17 | 72 | 252 | 88 | 0.00 |
![]() | 0 | 9 | 132 | 303 | 95 | 0.00 |
![]() | 0 | 16 | 66 | 177 | 41 | 0.00 |
![]() | 0 | 2 | 526 | 887 | 509 | 0.00 |
![]() | 0 | 1 | 1,045 | 1,045 | 0 | 0.00 |
![]() | 0 | 1 | 1,040 | 1,040 | 0 | 0.00 |
![]() | 0 | 8 | 128 | 612 | 197 | 0.00 |
![]() | 0 | 61 | 16 | 361 | 53 | 0.00 |
![]() | 0 | 11 | 90 | 432 | 115 | 0.00 |
![]() | 0 | 2 | 477 | 628 | 212 | 0.00 |
![]() | 0 | 1 | 919 | 919 | 0 | 0.00 |
![]() | 0 | 18 | 49 | 129 | 28 | 0.00 |
![]() | 0 | 2 | 446 | 534 | 124 | 0.00 |
![]() | 0 | 1 | 873 | 873 | 0 | 0.00 |
![]() ![]() SELECT ds.status as situacao, CASE WHEN substring(item.produto -> 'prod' ->> 'cfop', 1, 1) IN ('1', '2', '3') THEN 'DEVOLUCAO' WHEN substring(item.produto -> 'prod' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' ELSE 'DESCONHECIDO' end as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.key, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'xprod' as descricaoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) as valorProduto, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) as valorBaseCalculoPisCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as somatorioAliquotaPisCofins, ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) as valorRecolhidoPis, ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) as valorRecolhidoCofins, ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as valorTotalRecolhidoPisCofins, ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) as valorPisAposExclusao, ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) as valorCofinsAposExclusao, ( ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) + ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) ) as pisRecuperarAntesRevisao, ( ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) ) + ( ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) ) as valorTotalRecuperarAntesRevisao, ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) as baseLiquidaIcmsPisCofins, ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( 1 - ((CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC)) / 100) ) ) as novaBaseCalculoGrossupPisCofins, ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( 1 - ((CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC)) / 100) ) ) * ( (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC)) / 100 ) ) as pisCofinsDevidoRecalculado, ( ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( 1 - ((CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC)) / 100) ) ) * ( (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC)) / 100 ) ) ) as valorRecuperarAposRevisao, ( ( ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) + ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) ) / ( 1 - ((CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC)) / 100) ) ) * ( (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) + CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC)) / 100 ) ) ) - ( ( ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100 ) ) + ( ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) - ( ( ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) - CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100 ) ) ) ) as ganhoRevisao, d.cnpj_issuer as cnpj FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type , jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('NFE_4_0', 'NFE_3_1') AND CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 AND cast(coalesce(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) <> 0 AND d.data_emissao between ? and ? AND item.produto -> 'prod' ->> 'cfop' IN ( '5101', '5102', '5103', '5104', '5105', '5106', '5109', '5110', '5111', '5112', '5113', '5114', '5115', '5116', '5117', '5118', '5119', '5120', '5122', '5123', '5124', '5125', '5251', '5252', '5253', '5254', '5255', '5256', '5257', '5258', '5301', '5302', '5303', '5304', '5305', '5306', '5307', '5351', '5352', '5353', '5354', '5355', '5356', '5357', '5359', '5360', '5401', '5402', '5403', '5405', '5501', '5502', '5651', '5652', '5653', '5654', '5655', '5656', '5667', '5932', '6101', '6102', '6103', '6104', '6105', '6106', '6107', '6108', '6109', '6110', '6111', '6112', '6113', '6114', '6115', '6116', '6117', '6118', '6119', '6120', '6122', '6123', '6124', '6125', '6251', '6252', '6253', '6254', '6255', '6256', '6257', '6258', '6301', '6302', '6303', '6304', '6305', '6306', '6307', '6351', '6352', '6353', '6354', '6355', '6356', '6357', '6359', '6360', '6401', '6402', '6403', '6404', '6501', '6502', '6651', '6652', '6653', '6654', '6655', '6656', '6667', '6932', '7101', '7102', '7105', '7106', '7127', '7251', '7301', '7358', '7501', '7651', '7654', '7667', '1201', '1202', '1203', '1204', '1205', '1206', '1207', '1410', '1411', '1503', '1504', '1660', '1661', '1662', '2201', '2202', '2203', '2204', '2205', '2206', '2207', '2410', '2411', '2503', '2504', '2660', '2661', '2662', '3201', '3202', '3205', '3206', '3207', '3211', '3503' ) AND ( CAST(COALESCE(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc', item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc') AS NUMERIC) >= CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) ) limit ? | 0 | 61 | 14 | 25 | 2 | 0.00 |
![]() | 0 | 109 | 7 | 32 | 7 | 0.00 |
![]() | 0 | 9 | 94 | 227 | 85 | 0.00 |
![]() | 0 | 27 | 31 | 41 | 2 | 0.00 |
![]() | 0 | 17 | 49 | 99 | 18 | 0.00 |
![]() | 0 | 114 | 6 | 43 | 7 | 0.00 |
![]() | 0 | 9 | 78 | 140 | 36 | 0.00 |
![]() | 0 | 61 | 11 | 14 | 1 | 0.00 |
![]() | 0 | 1 | 672 | 672 | 0 | 0.00 |
![]() | 0 | 1 | 660 | 660 | 0 | 0.00 |
![]() | 0 | 10 | 60 | 223 | 82 | 0.00 |
![]() | 0 | 1 | 589 | 589 | 0 | 0.00 |
![]() | 0 | 4 | 141 | 141 | 0 | 0.00 |
![]() | 0 | 1 | 558 | 558 | 0 | 0.00 |
![]() | 0 | 1 | 548 | 548 | 0 | 0.00 |
![]() | 0 | 9 | 59 | 317 | 96 | 0.00 |
![]() ![]() SELECT SUM(CAST(d.data ->'nfe'->'infNFe'->'cobr'->'fat'->>'vliq' AS NUMERIC)) AS total_valor_liquido, SUM(CAST(d.data ->'nfe'->'infNFe'->'cobr'->'fat'->>'vdesc' AS NUMERIC)) AS total_valor_desconto, SUM(CAST(d.data ->'nfe'->'infNFe'->'cobr'->'fat'->>'vorig' AS NUMERIC)) AS total_valor_origem, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vnf' AS NUMERIC)) AS total_vnf, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vbc' AS NUMERIC)) AS total_vbc, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vbcst' AS NUMERIC)) AS total_vbcst, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vst' AS NUMERIC)) AS total_vst, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vprod' AS NUMERIC)) AS total_vprod, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vipi' AS NUMERIC)) AS total_vipi, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vpis' AS NUMERIC)) AS total_vpis, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vcofins' AS NUMERIC)) AS total_vcofins, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'voutro' AS NUMERIC)) AS total_voutro, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vicms' AS NUMERIC)) AS total_vicms, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vfrete' AS NUMERIC)) AS total_frete FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type left join canhoto_nota cn on d.key = cn.documento_chave and d.cnpj_issuer = cn.empresa_cnpj WHERE d.cnpj_issuer = ? and d.type IN (?, ?, ?) and d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and d.data_emissao between ? and ? | 0 | 1 | 535 | 535 | 0 | 0.00 |
![]() | 0 | 96 | 5 | 25 | 4 | 0.00 |
![]() | 0 | 1 | 528 | 528 | 0 | 0.00 |
![]() | 0 | 219 | 2 | 13 | 1 | 0.00 |
![]() | 0 | 8 | 65 | 89 | 13 | 0.00 |
![]() | 0 | 2 | 250 | 360 | 155 | 0.00 |
![]() | 0 | 137 | 3 | 51 | 5 | 0.00 |
![]() | 0 | 9 | 53 | 83 | 12 | 0.00 |
![]() | 0 | 6 | 78 | 139 | 39 | 0.00 |
![]() | 0 | 1 | 455 | 455 | 0 | 0.00 |
![]() | 0 | 2 | 226 | 437 | 297 | 0.00 |
![]() | 0 | 1 | 449 | 449 | 0 | 0.00 |
![]() | 0 | 18 | 24 | 89 | 24 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpj, CASE WHEN substring(item.produto -> 'prod' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' ELSE 'DEVOLUCAO' END as tipoOperacao, d.data_emissao as dataEmissao, d.key, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'xprod' as descricaoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) as valorProduto, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) as baseCalculoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) as baseCalculoCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) as valorRecolhidoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) as valorRecolhidoCofins, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as baseCalculoIcms, ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as novaBaseCalculoIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcmsAntesExclusao, ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsAposExclusao, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsRestituir FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type , jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE ds.status = '1' AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') and CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) <> 0 AND item.produto -> 'prod' ->> 'cfop' IN ( '5101','5102','5103','5104','5105','5106','5109','5110','5111','5112','5113','5114','5115','5116','5117','5118','5119','5120','5122','5123','5124','5125','5251','5252','5253','5254','5255','5256','5257','5258','5301','5302','5303','5304','5305','5306','5307','5351','5352','5353','5354','5355','5356','5357','5359','5360','5401','5402','5403','5405','5414','5415','5451','5501','5502','5554','5651','5652','5653','5654','5655','5656','5657,5663','5666','5667','5901','5904','5905','5908','5910','5911','5912','5914','5915','5917','5920','5923','5924','5932', '6101','6102','6103','6104','6105','6106','6107','6108','6109','6110','6111','6112','6113','6114','6115','6116','6117','6118','6119','6120','6122','6123','6124','6125','6251,6252','6253','6254','6255','6256','6257','6258','6301','6302','6303','6304','6305','6306','6307','6351','6352','6353','6354','6355','6356','6357','6359','6360','6401','6402','6403','6404','6414','6415','6501','6502','6554','6651','6652','6653','6654','6655','6656','6657','6663','6666','6667','6901','6904','6905','6908','6910','6911','6912','6914','6915','6917','6920','6923','6924','6932', '7101','7102','7105','7106','7127','7251','7301','7358','7501','7651','7654','7667', '1201','1202','1203','1204','1205','1206','1207','1410','1411','1503','1504','1660','1661','1662', '2201','2202','2203','2204','2205','2206','2207','2410','2411','2503','2504','2660','2661','2662', '3201','3202','3205','3206','3207','3211','3503' ) AND d.cnpj_issuer = ? AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) ) > 0 AND NOT EXISTS ( SELECT 1 FROM exclusao_pis_cofins_base_calculo_icms epcbci WHERE epcbci.key = d.key AND epcbci.cnpj = ? ) ORDER BY d.data_emissao limit ? | 0 | 7 | 63 | 66 | 3 | 0.00 |
![]() | 0 | 1 | 415 | 415 | 0 | 0.00 |
![]() | 0 | 11 | 35 | 107 | 24 | 0.00 |
![]() | 0 | 11 | 35 | 106 | 34 | 0.00 |
![]() | 0 | 59 | 6 | 15 | 2 | 0.00 |
![]() | 0 | 12 | 31 | 158 | 40 | 0.00 |
![]() | 0 | 61 | 6 | 27 | 3 | 0.00 |
![]() | 0 | 122 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 8 | 45 | 142 | 42 | 0.00 |
![]() | 0 | 11 | 33 | 147 | 39 | 0.00 |
![]() | 0 | 61 | 5 | 16 | 2 | 0.00 |
![]() | 0 | 1 | 359 | 359 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 3 | 116 | 129 | 10 | 0.00 |
![]() | 0 | 3 | 112 | 194 | 94 | 0.00 |
![]() | 0 | 1 | 334 | 334 | 0 | 0.00 |
![]() | 0 | 1 | 332 | 332 | 0 | 0.00 |
![]() | 0 | 61 | 5 | 16 | 2 | 0.00 |
![]() | 0 | 27 | 11 | 24 | 5 | 0.00 |
![]() | 0 | 28 | 11 | 27 | 6 | 0.00 |
![]() | 0 | 14 | 22 | 230 | 59 | 0.00 |
![]() | 0 | 118 | 2 | 6 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 149 | 159 | 14 | 0.00 |
![]() | 0 | 2 | 147 | 155 | 10 | 0.00 |
![]() | 0 | 17 | 17 | 40 | 11 | 0.00 |
![]() | 0 | 41 | 6 | 18 | 2 | 0.00 |
![]() | 0 | 38 | 7 | 16 | 2 | 0.00 |
![]() | 0 | 9 | 30 | 57 | 10 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 136 | 145 | 12 | 0.00 |
![]() | 0 | 28 | 9 | 24 | 6 | 0.00 |
![]() | 0 | 50 | 5 | 53 | 7 | 0.00 |
![]() | 0 | 122 | 2 | 3 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 133 | 144 | 14 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 130 | 138 | 11 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 130 | 137 | 9 | 0.00 |
![]() | 0 | 4 | 65 | 173 | 73 | 0.00 |
![]() | 0 | 3 | 85 | 86 | 0 | 0.00 |
![]() | 0 | 1 | 255 | 255 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 127 | 131 | 4 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 124 | 139 | 20 | 0.00 |
![]() | 0 | 2 | 120 | 166 | 64 | 0.00 |
![]() | 0 | 41 | 5 | 11 | 1 | 0.00 |
![]() | 0 | 2 | 117 | 118 | 0 | 0.00 |
![]() | 0 | 61 | 3 | 12 | 1 | 0.00 |
![]() | 0 | 65 | 3 | 12 | 1 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 114 | 115 | 1 | 0.00 |
![]() | 0 | 6 | 37 | 40 | 1 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 112 | 114 | 2 | 0.00 |
![]() | 0 | 3 | 74 | 201 | 109 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 2 | 111 | 114 | 3 | 0.00 |
![]() | 0 | 41 | 5 | 8 | 1 | 0.00 |
![]() | 0 | 39 | 5 | 25 | 4 | 0.00 |
![]() ![]() SELECT SUM(CAST(d.data ->'nfe'->'infNFe'->'cobr'->'fat'->>'vliq' AS NUMERIC)) AS total_valor_liquido, SUM(CAST(d.data ->'nfe'->'infNFe'->'cobr'->'fat'->>'vdesc' AS NUMERIC)) AS total_valor_desconto, SUM(CAST(d.data ->'nfe'->'infNFe'->'cobr'->'fat'->>'vorig' AS NUMERIC)) AS total_valor_origem, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vnf' AS NUMERIC)) AS total_vnf, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vbc' AS NUMERIC)) AS total_vbc, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vbcst' AS NUMERIC)) AS total_vbcst, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vst' AS NUMERIC)) AS total_vst, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vprod' AS NUMERIC)) AS total_vprod, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vipi' AS NUMERIC)) AS total_vipi, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vpis' AS NUMERIC)) AS total_vpis, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vcofins' AS NUMERIC)) AS total_vcofins, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'voutro' AS NUMERIC)) AS total_voutro, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vicms' AS NUMERIC)) AS total_vicms, SUM(CAST(d.data ->'nfe'->'infNFe'->'total'->'icmsTot'->>'vfrete' AS NUMERIC)) AS total_frete FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE d.cnpj_addressee = ? and d.type IN (?, ?, ?) and d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and d.data_emissao between ? and ? | 0 | 2 | 106 | 107 | 0 | 0.00 |
![]() | 0 | 5 | 42 | 78 | 19 | 0.00 |
![]() | 0 | 5 | 42 | 56 | 7 | 0.00 |
![]() | 0 | 3 | 69 | 70 | 0 | 0.00 |
![]() | 0 | 3 | 69 | 176 | 92 | 0.00 |
![]() | 0 | 34 | 6 | 22 | 4 | 0.00 |
![]() | 0 | 3 | 68 | 168 | 86 | 0.00 |
![]() | 0 | 61 | 3 | 11 | 1 | 0.00 |
![]() | 0 | 10 | 19 | 64 | 17 | 0.00 |
![]() | 0 | 23 | 8 | 16 | 2 | 0.00 |
![]() | 0 | 4 | 48 | 67 | 17 | 0.00 |
![]() | 0 | 2 | 96 | 98 | 2 | 0.00 |
![]() | 0 | 1 | 190 | 190 | 0 | 0.00 |
![]() | 0 | 21 | 9 | 23 | 6 | 0.00 |
![]() | 0 | 5 | 37 | 39 | 1 | 0.00 |
![]() | 0 | 21 | 8 | 25 | 5 | 0.00 |
![]() | 0 | 1 | 184 | 184 | 0 | 0.00 |
![]() | 0 | 1 | 184 | 184 | 0 | 0.00 |
![]() | 0 | 14 | 12 | 31 | 8 | 0.00 |
![]() | 0 | 1 | 180 | 180 | 0 | 0.00 |
![]() | 0 | 4 | 44 | 61 | 17 | 0.00 |
![]() | 0 | 4 | 43 | 145 | 67 | 0.00 |
![]() | 0 | 6 | 28 | 69 | 24 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpj, CASE WHEN substring(item.produto -> 'prod' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' ELSE 'DEVOLUCAO' END as tipoOperacao, d.data_emissao as dataEmissao, d.key, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'xprod' as descricaoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) as valorProduto, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) as baseCalculoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) as baseCalculoCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) as valorRecolhidoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) as valorRecolhidoCofins, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as baseCalculoIcms, ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as novaBaseCalculoIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcmsAntesExclusao, ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsAposExclusao, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsRestituir FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type , jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE ds.status = '1' AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') and CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) <> 0 AND item.produto -> 'prod' ->> 'cfop' IN ( '5101','5102','5103','5104','5105','5106','5109','5110','5111','5112','5113','5114','5115','5116','5117','5118','5119','5120','5122','5123','5124','5125','5251','5252','5253','5254','5255','5256','5257','5258','5301','5302','5303','5304','5305','5306','5307','5351','5352','5353','5354','5355','5356','5357','5359','5360','5401','5402','5403','5405','5414','5415','5451','5501','5502','5554','5651','5652','5653','5654','5655','5656','5657,5663','5666','5667','5901','5904','5905','5908','5910','5911','5912','5914','5915','5917','5920','5923','5924','5932', '6101','6102','6103','6104','6105','6106','6107','6108','6109','6110','6111','6112','6113','6114','6115','6116','6117','6118','6119','6120','6122','6123','6124','6125','6251,6252','6253','6254','6255','6256','6257','6258','6301','6302','6303','6304','6305','6306','6307','6351','6352','6353','6354','6355','6356','6357','6359','6360','6401','6402','6403','6404','6414','6415','6501','6502','6554','6651','6652','6653','6654','6655','6656','6657','6663','6666','6667','6901','6904','6905','6908','6910','6911','6912','6914','6915','6917','6920','6923','6924','6932', '7101','7102','7105','7106','7127','7251','7301','7358','7501','7651','7654','7667', '1201','1202','1203','1204','1205','1206','1207','1410','1411','1503','1504','1660','1661','1662', '2201','2202','2203','2204','2205','2206','2207','2410','2411','2503','2504','2660','2661','2662', '3201','3202','3205','3206','3207','3211','3503' ) AND d.cnpj_issuer = ? AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) ) > 0 AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) | 0 | 2 | 84 | 86 | 2 | 0.00 |
![]() | 0 | 6 | 27 | 37 | 5 | 0.00 |
![]() | 0 | 36 | 4 | 24 | 5 | 0.00 |
![]() | 0 | 70 | 2 | 4 | 0 | 0.00 |
![]() | 0 | 33 | 5 | 27 | 5 | 0.00 |
![]() | 0 | 1 | 164 | 164 | 0 | 0.00 |
![]() | 0 | 33 | 4 | 35 | 5 | 0.00 |
![]() | 0 | 8 | 20 | 93 | 30 | 0.00 |
![]() | 0 | 38 | 4 | 17 | 2 | 0.00 |
![]() | 0 | 6 | 26 | 35 | 6 | 0.00 |
![]() | 0 | 2 | 77 | 79 | 2 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 155 | 155 | 0 | 0.00 |
![]() | 0 | 7 | 21 | 34 | 11 | 0.00 |
![]() | 0 | 2 | 76 | 81 | 7 | 0.00 |
![]() | 0 | 61 | 2 | 18 | 2 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 151 | 151 | 0 | 0.00 |
![]() | 0 | 7 | 21 | 67 | 23 | 0.00 |
![]() | 0 | 1 | 147 | 147 | 0 | 0.00 |
![]() | 0 | 2 | 72 | 77 | 6 | 0.00 |
![]() | 0 | 2 | 71 | 110 | 54 | 0.00 |
![]() | 0 | 32 | 4 | 24 | 4 | 0.00 |
![]() | 0 | 33 | 4 | 27 | 4 | 0.00 |
![]() | 0 | 61 | 2 | 7 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 139 | 139 | 0 | 0.00 |
![]() | 0 | 61 | 2 | 12 | 1 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 137 | 137 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 137 | 137 | 0 | 0.00 |
![]() | 0 | 2 | 68 | 73 | 7 | 0.00 |
![]() | 0 | 2 | 68 | 128 | 84 | 0.00 |
![]() | 0 | 61 | 2 | 13 | 1 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 134 | 134 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 134 | 134 | 0 | 0.00 |
![]() | 0 | 61 | 2 | 8 | 1 | 0.00 |
![]() | 0 | 1 | 134 | 134 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 134 | 134 | 0 | 0.00 |
![]() | 0 | 2 | 67 | 104 | 52 | 0.00 |
![]() | 0 | 22 | 6 | 46 | 9 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 132 | 132 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 132 | 132 | 0 | 0.00 |
![]() | 0 | 1 | 132 | 132 | 0 | 0.00 |
![]() | 0 | 61 | 2 | 12 | 1 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 130 | 130 | 0 | 0.00 |
![]() | 0 | 36 | 3 | 25 | 3 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 129 | 129 | 0 | 0.00 |
![]() | 0 | 2 | 64 | 70 | 7 | 0.00 |
![]() | 0 | 9 | 14 | 37 | 11 | 0.00 |
![]() | 0 | 61 | 2 | 9 | 0 | 0.00 |
![]() | 0 | 61 | 2 | 9 | 1 | 0.00 |
![]() | 0 | 22 | 5 | 30 | 6 | 0.00 |
![]() | 0 | 5 | 24 | 66 | 23 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 123 | 123 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 123 | 123 | 0 | 0.00 |
![]() | 0 | 10 | 12 | 25 | 9 | 0.00 |
![]() | 0 | 61 | 1 | 10 | 1 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 121 | 121 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 121 | 121 | 0 | 0.00 |
![]() | 0 | 5 | 24 | 49 | 18 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 120 | 120 | 0 | 0.00 |
![]() | 0 | 39 | 3 | 4 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 120 | 120 | 0 | 0.00 |
![]() | 0 | 6 | 20 | 21 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 119 | 119 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 118 | 118 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 117 | 117 | 0 | 0.00 |
![]() | 0 | 2 | 58 | 81 | 31 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 117 | 117 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 117 | 117 | 0 | 0.00 |
![]() | 0 | 4 | 29 | 50 | 19 | 0.00 |
![]() | 0 | 4 | 29 | 37 | 5 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 115 | 115 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 115 | 115 | 0 | 0.00 |
![]() | 0 | 9 | 12 | 36 | 8 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 114 | 114 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 114 | 114 | 0 | 0.00 |
![]() | 0 | 1 | 113 | 113 | 0 | 0.00 |
![]() | 0 | 1 | 111 | 111 | 0 | 0.00 |
![]() | 0 | 8 | 13 | 19 | 4 | 0.00 |
![]() | 0 | 16 | 6 | 14 | 2 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 110 | 110 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 110 | 110 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 110 | 110 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 109 | 109 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 109 | 109 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 109 | 109 | 0 | 0.00 |
![]() | 0 | 3 | 36 | 63 | 29 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 108 | 108 | 0 | 0.00 |
![]() ![]() SELECT * FROM ( SELECT d.cnpj_issuer as cnpjEmitente, ds.status as situacao, CASE WHEN substring(d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' END as tipoOperacao, d.data_emissao as dataEmissao, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'nct' as numeroNotaFiscal, d.key, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, null as codigoProduto, null as descricaoProduto, d.data -> 'cte' -> 'infCte' -> 'ide' ->> 'cfop' as cfop, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorProduto, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as valorBaseCalculoIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'picms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcms, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) as valorBaseCalculoPisCofins, 1.65 as aliquotaPis, 7.6 as aliquotaCofins, 9.25 as somatorioAliquotaPisCofins, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) as valorRecolhidoPis, CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) as valorRecolhidoCofins, (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100)) + (CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100)) as valorTotalRecolhidoPisCofins, ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) as baseCalculoAposExclusaoAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (1.65 / 100) ) as valorPisAposExclusao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) * (7.6 / 100) ) as valorCofinsAposExclusao, ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as valorTotalPisCofinsAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) as pisRecuperarAntesRevisao, ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) as cofinsRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (1.65 / 100) ) ) + ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) - ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * (7.6 / 100) ) ) ) as valorTotalRecuperarAntesRevisao, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) as novaBaseGroussUpPisCofins, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 as pisGroussUp, ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 as cofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) as pisCofinsGroussUp, ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 1.65 / 100 ) + ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) ) * 7.6 / 100 ) ) - ( ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 1.65 / 100 ) + ( ( ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) - CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) ) - ( ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (1.65 / 100) ) + ( CAST(d.data -> 'cte' -> 'infCte' -> 'vprest' ->> 'vtPrest' AS NUMERIC) * (7.6 / 100) ) ) ) / ( ( 100 - ( 1.65 + 7.6 ) ) / 100 ) ) * 7.6 / 100 ) ) ) as ganhoGroussUp FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type WHERE ds.status = '1' AND d.cnpj_issuer = ? AND d.type IN ('CTE','CTE_OS') AND CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vbc', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) <> 0 and CAST(COALESCE(d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms00' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms10' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms20' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms70' ->> 'vicms', d.data -> 'cte' -> 'infCte' -> 'imp' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ) as resultado WHERE ganhoGroussUp > 0 | 0 | 1 | 108 | 108 | 0 | 0.00 |
![]() | 0 | 2 | 53 | 73 | 27 | 0.00 |
![]() | 0 | 3 | 35 | 60 | 24 | 0.00 |
![]() | 0 | 1 | 106 | 106 | 0 | 0.00 |
![]() | 0 | 7 | 15 | 33 | 10 | 0.00 |
![]() | 0 | 2 | 52 | 53 | 0 | 0.00 |
![]() | 0 | 4 | 25 | 77 | 34 | 0.00 |
![]() | 0 | 3 | 34 | 47 | 20 | 0.00 |
![]() | 0 | 4 | 25 | 40 | 10 | 0.00 |
![]() | 0 | 1 | 100 | 100 | 0 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpj, CASE WHEN substring(item.produto -> 'prod' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' ELSE 'DEVOLUCAO' END as tipoOperacao, d.data_emissao as dataEmissao, d.key, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'xprod' as descricaoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) as valorProduto, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) as baseCalculoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) as baseCalculoCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) as valorRecolhidoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) as valorRecolhidoCofins, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as baseCalculoIcms, ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as novaBaseCalculoIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcmsAntesExclusao, ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsAposExclusao, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsRestituir FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type , jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE ds.status = '1' AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') and CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) <> 0 AND item.produto -> 'prod' ->> 'cfop' IN ( '5101','5102','5103','5104','5105','5106','5109','5110','5111','5112','5113','5114','5115','5116','5117','5118','5119','5120','5122','5123','5124','5125','5251','5252','5253','5254','5255','5256','5257','5258','5301','5302','5303','5304','5305','5306','5307','5351','5352','5353','5354','5355','5356','5357','5359','5360','5401','5402','5403','5405','5414','5415','5451','5501','5502','5554','5651','5652','5653','5654','5655','5656','5657,5663','5666','5667','5901','5904','5905','5908','5910','5911','5912','5914','5915','5917','5920','5923','5924','5932', '6101','6102','6103','6104','6105','6106','6107','6108','6109','6110','6111','6112','6113','6114','6115','6116','6117','6118','6119','6120','6122','6123','6124','6125','6251,6252','6253','6254','6255','6256','6257','6258','6301','6302','6303','6304','6305','6306','6307','6351','6352','6353','6354','6355','6356','6357','6359','6360','6401','6402','6403','6404','6414','6415','6501','6502','6554','6651','6652','6653','6654','6655','6656','6657','6663','6666','6667','6901','6904','6905','6908','6910','6911','6912','6914','6915','6917','6920','6923','6924','6932', '7101','7102','7105','7106','7127','7251','7301','7358','7501','7651','7654','7667', '1201','1202','1203','1204','1205','1206','1207','1410','1411','1503','1504','1660','1661','1662', '2201','2202','2203','2204','2205','2206','2207','2410','2411','2503','2504','2660','2661','2662', '3201','3202','3205','3206','3207','3211','3503' ) AND d.cnpj_issuer = ? AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) ) > 0 AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) | 0 | 1 | 97 | 97 | 0 | 0.00 |
![]() | 0 | 3 | 32 | 40 | 9 | 0.00 |
![]() | 0 | 1 | 96 | 96 | 0 | 0.00 |
![]() | 0 | 14 | 6 | 20 | 4 | 0.00 |
![]() | 0 | 1 | 95 | 95 | 0 | 0.00 |
![]() | 0 | 2 | 46 | 66 | 27 | 0.00 |
![]() | 0 | 4 | 22 | 48 | 18 | 0.00 |
![]() | 0 | 4 | 22 | 47 | 18 | 0.00 |
![]() | 0 | 2 | 44 | 66 | 31 | 0.00 |
![]() | 0 | 1 | 87 | 87 | 0 | 0.00 |
![]() | 0 | 5 | 17 | 44 | 16 | 0.00 |
![]() | 0 | 4 | 21 | 30 | 7 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpj, CASE WHEN substring(item.produto -> 'prod' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' ELSE 'DEVOLUCAO' END as tipoOperacao, d.data_emissao as dataEmissao, d.key, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'xprod' as descricaoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) as valorProduto, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) as baseCalculoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) as baseCalculoCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) as valorRecolhidoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) as valorRecolhidoCofins, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as baseCalculoIcms, ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as novaBaseCalculoIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcmsAntesExclusao, ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsAposExclusao, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsRestituir FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type , jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE ds.status = '1' AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') and CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) <> 0 AND item.produto -> 'prod' ->> 'cfop' IN ( '5101','5102','5103','5104','5105','5106','5109','5110','5111','5112','5113','5114','5115','5116','5117','5118','5119','5120','5122','5123','5124','5125','5251','5252','5253','5254','5255','5256','5257','5258','5301','5302','5303','5304','5305','5306','5307','5351','5352','5353','5354','5355','5356','5357','5359','5360','5401','5402','5403','5405','5414','5415','5451','5501','5502','5554','5651','5652','5653','5654','5655','5656','5657,5663','5666','5667','5901','5904','5905','5908','5910','5911','5912','5914','5915','5917','5920','5923','5924','5932', '6101','6102','6103','6104','6105','6106','6107','6108','6109','6110','6111','6112','6113','6114','6115','6116','6117','6118','6119','6120','6122','6123','6124','6125','6251,6252','6253','6254','6255','6256','6257','6258','6301','6302','6303','6304','6305','6306','6307','6351','6352','6353','6354','6355','6356','6357','6359','6360','6401','6402','6403','6404','6414','6415','6501','6502','6554','6651','6652','6653','6654','6655','6656','6657','6663','6666','6667','6901','6904','6905','6908','6910','6911','6912','6914','6915','6917','6920','6923','6924','6932', '7101','7102','7105','7106','7127','7251','7301','7358','7501','7651','7654','7667', '1201','1202','1203','1204','1205','1206','1207','1410','1411','1503','1504','1660','1661','1662', '2201','2202','2203','2204','2205','2206','2207','2410','2411','2503','2504','2660','2661','2662', '3201','3202','3205','3206','3207','3211','3503' ) AND d.cnpj_issuer = ? AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) ) > 0 AND d.key in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) | 0 | 1 | 86 | 86 | 0 | 0.00 |
![]() | 0 | 1 | 84 | 84 | 0 | 0.00 |
![]() | 0 | 1 | 84 | 84 | 0 | 0.00 |
![]() | 0 | 4 | 21 | 32 | 9 | 0.00 |
![]() | 0 | 2 | 41 | 78 | 51 | 0.00 |
![]() | 0 | 7 | 11 | 23 | 6 | 0.00 |
![]() | 0 | 3 | 27 | 47 | 18 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 39 | 54 | 20 | 0.00 |
![]() | 0 | 9 | 8 | 14 | 3 | 0.00 |
![]() | 0 | 8 | 9 | 22 | 5 | 0.00 |
![]() | 0 | 2 | 38 | 67 | 40 | 0.00 |
![]() | 0 | 2 | 37 | 58 | 28 | 0.00 |
![]() | 0 | 25 | 2 | 5 | 0 | 0.00 |
![]() | 0 | 1 | 69 | 69 | 0 | 0.00 |
![]() | 0 | 1 | 68 | 68 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 33 | 37 | 5 | 0.00 |
![]() | 0 | 4 | 16 | 26 | 11 | 0.00 |
![]() | 0 | 1 | 66 | 66 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 33 | 38 | 7 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 32 | 42 | 14 | 0.00 |
![]() | 0 | 8 | 8 | 24 | 7 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 31 | 37 | 7 | 0.00 |
![]() | 0 | 3 | 21 | 46 | 22 | 0.00 |
![]() | 0 | 1 | 62 | 62 | 0 | 0.00 |
![]() | 0 | 1 | 62 | 62 | 0 | 0.00 |
![]() | 0 | 5 | 12 | 27 | 8 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 30 | 36 | 7 | 0.00 |
![]() ![]() SELECT d.cnpj_issuer as cnpj, CASE WHEN substring(item.produto -> 'prod' ->> 'cfop', 1, 1) IN ('5', '6', '7') THEN 'VENDA' ELSE 'DEVOLUCAO' END as tipoOperacao, d.data_emissao as dataEmissao, d.key, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'nnf' as numeroNotaFiscal, d.data -> 'nfe' -> 'infNFe' -> 'ide' ->> 'serie' as serie, d.cnpj_addressee as cnpjDestinatario, item.produto -> 'prod' ->> 'cprod' as codigoProduto, item.produto -> 'prod' ->> 'xprod' as descricaoProduto, item.produto -> 'prod' ->> 'cfop' as cfop, CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) as valorProduto, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) as baseCalculoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) as baseCalculoCofins, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) as aliquotaPis, CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) as valorRecolhidoPis, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) as aliquotaCofins, CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) as valorRecolhidoCofins, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vbc', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vbc') as numeric) as baseCalculoIcms, ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) as novaBaseCalculoIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) as aliquotaIcms, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) as valorIcmsAntesExclusao, ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsAposExclusao, CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) as valorIcmsRestituir FROM document d INNER JOIN document_status ds ON d.key = ds.key and d.cnpj_issuer = ds.cnpj_issuer and d.protocol = ds.protocol and d.nsu = ds.nsu and d.type = ds.type , jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) WHERE ds.status = '1' AND d.type IN ('NFE_4_0', 'NFE_3_1', 'NFE_2_0') and CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) <> 0 AND CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vpis' AS NUMERIC) <> 0 AND CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vcofins' AS NUMERIC) <> 0 AND item.produto -> 'prod' ->> 'cfop' IN ( '5101','5102','5103','5104','5105','5106','5109','5110','5111','5112','5113','5114','5115','5116','5117','5118','5119','5120','5122','5123','5124','5125','5251','5252','5253','5254','5255','5256','5257','5258','5301','5302','5303','5304','5305','5306','5307','5351','5352','5353','5354','5355','5356','5357','5359','5360','5401','5402','5403','5405','5414','5415','5451','5501','5502','5554','5651','5652','5653','5654','5655','5656','5657,5663','5666','5667','5901','5904','5905','5908','5910','5911','5912','5914','5915','5917','5920','5923','5924','5932', '6101','6102','6103','6104','6105','6106','6107','6108','6109','6110','6111','6112','6113','6114','6115','6116','6117','6118','6119','6120','6122','6123','6124','6125','6251,6252','6253','6254','6255','6256','6257','6258','6301','6302','6303','6304','6305','6306','6307','6351','6352','6353','6354','6355','6356','6357','6359','6360','6401','6402','6403','6404','6414','6415','6501','6502','6554','6651','6652','6653','6654','6655','6656','6657','6663','6666','6667','6901','6904','6905','6908','6910','6911','6912','6914','6915','6917','6920','6923','6924','6932', '7101','7102','7105','7106','7127','7251','7301','7358','7501','7651','7654','7667', '1201','1202','1203','1204','1205','1206','1207','1410','1411','1503','1504','1660','1661','1662', '2201','2202','2203','2204','2205','2206','2207','2410','2411','2503','2504','2660','2661','2662', '3201','3202','3205','3206','3207','3211','3503' ) AND d.cnpj_issuer = ? AND d.data_emissao BETWEEN CAST(? AS DATE) and CAST(? AS DATE) AND ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'vicms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'vicms') as numeric) - ( ( CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC) - ( CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'pis' -> 'pisAliq' ->> 'ppis' AS NUMERIC) / 100) ) - ( CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'vbc' AS NUMERIC) * (CAST(item.produto -> 'imposto' -> 'cofins' -> 'cofinsAliq' ->> 'pcofins' AS NUMERIC) / 100) ) ) * ( CAST(COALESCE(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms10' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms20' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms70' ->> 'picms', item.produto -> 'imposto' -> 'icms' -> 'icms90' ->> 'picms') as numeric) / 100 ) ) ) > 0 AND d.key in (?, ?) | 0 | 1 | 60 | 60 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 30 | 32 | 2 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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UP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 29 | 35 | 7 | 0.00 |
![]() | 0 | 8 | 7 | 12 | 3 | 0.00 |
![]() | 0 | 1 | 58 | 58 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 29 | 36 | 9 | 0.00 |
![]() | 0 | 2 | 28 | 39 | 14 | 0.00 |
![]() | 0 | 1 | 57 | 57 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 28 | 31 | 3 | 0.00 |
![]() | 0 | 6 | 9 | 16 | 3 | 0.00 |
![]() | 0 | 8 | 7 | 13 | 2 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 28 | 31 | 4 | 0.00 |
![]() | 0 | 6 | 9 | 11 | 1 | 0.00 |
![]() | 0 | 3 | 18 | 25 | 9 | 0.00 |
![]() | 0 | 2 | 27 | 30 | 4 | 0.00 |
![]() | 0 | 1 | 54 | 54 | 0 | 0.00 |
![]() | 0 | 6 | 9 | 14 | 2 | 0.00 |
![]() | 0 | 2 | 27 | 39 | 16 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 27 | 30 | 4 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 26 | 32 | 7 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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R(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 26 | 28 | 2 | 0.00 |
![]() | 0 | 16 | 3 | 11 | 2 | 0.00 |
![]() | 0 | 1 | 52 | 52 | 0 | 0.00 |
![]() | 0 | 2 | 26 | 30 | 5 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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e' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 25 | 27 | 2 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 25 | 28 | 4 | 0.00 |
![]() | 0 | 2 | 25 | 32 | 9 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 25 | 29 | 5 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 25 | 28 | 4 | 0.00 |
![]() | 0 | 10 | 5 | 20 | 5 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 25 | 29 | 5 | 0.00 |
![]() | 0 | 4 | 12 | 13 | 0 | 0.00 |
![]() | 0 | 4 | 12 | 20 | 5 | 0.00 |
![]() | 0 | 2 | 24 | 39 | 20 | 0.00 |
![]() | 0 | 3 | 16 | 30 | 12 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 23 | 27 | 4 | 0.00 |
![]() | 0 | 2 | 23 | 36 | 17 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' ->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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 23 | 24 | 0 | 0.00 |
![]() | 0 | 1 | 46 | 46 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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E_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 23 | 25 | 2 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC )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?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 23 | 25 | 2 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 23 | 25 | 2 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 23 | 25 | 2 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 22 | 23 | 0 | 0.00 |
![]() | 0 | 9 | 5 | 19 | 5 | 0.00 |
![]() | 0 | 1 | 45 | 45 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FRO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->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 22 | 24 | 2 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 22 | 22 | 0 | 0.00 |
![]() | 0 | 1 | 43 | 43 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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-> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 21 | 24 | 4 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 21 | 21 | 0 | 0.00 |
![]() | 0 | 3 | 13 | 27 | 11 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 20 | 21 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> '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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 20 | 21 | 1 | 0.00 |
![]() | 0 | 9 | 4 | 7 | 1 | 0.00 |
![]() | 0 | 2 | 19 | 28 | 12 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND d.type IN ('NFE_4_0','NFE_3_1','CFE_0_7','CFE_0_8') AND d.data_emissao BETWEEN ? AND ? AND item.produto -> 'prod' ->> 'cfop' IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 19 | 20 | 0 | 0.00 |
![]() ![]() WITH produtos AS ( SELECT TO_CHAR(d.data_emissao, 'YYYY-MM') AS periodo, d.data -> 'nfe' -> 'infNFe' ->> 'ie' AS inscricaoEstadual, item.produto -> 'prod' ->> 'cprod' AS codigo, item.produto -> 'prod' ->> 'xprod' AS nome, item.produto -> 'prod' ->> 'ncm' AS codigoNcm, item.produto -> 'prod' ->> 'ucom' AS descricaoUnidadeMedida, SUM(CAST(item.produto -> 'prod' ->> 'qcom' AS NUMERIC)) AS quantidade, SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) AS valor, row_number() OVER ( PARTITION BY TO_CHAR(d.data_emissao, 'YYYY-MM') ORDER BY SUM(CAST(item.produto -> 'prod' ->> 'vprod' AS NUMERIC)) DESC ) AS rank FROM document d CROSS JOIN LATERAL jsonb_array_elements( CASE WHEN d.type IN ('NFE_4_0','NFE_3_1') THEN d.data -> 'nfe' -> 'infNFe' -> 'det' ELSE d.data -> 'infCFe' -> 'det' END ) WITH ORDINALITY AS item(produto) WHERE d.cnpj_issuer = ? AND d.key IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 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, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) GROUP BY TO_CHAR(d.data_emissao, 'YYYY-MM'), d.data -> 'nfe' -> 'infNFe' ->> 'ie', item.produto -> 'prod' ->> 'cprod', item.produto -> 'prod' ->> 'xprod', item.produto -> 'prod' ->> 'ncm', item.produto -> 'prod' ->> 'ucom' ) SELECT periodo, inscricaoEstadual, codigo, nome, codigoNcm, descricaoUnidadeMedida, SUM(quantidade) AS quantidade, SUM(valor) AS valor FROM produtos WHERE rank <= ? GROUP BY periodo, codigo, nome, codigoNcm, descricaoUnidadeMedida, inscricaoEstadual | 0 | 2 | 19 | 20 | 0 | 0.00 |
![]() | 0 | 2 | 19 | 27 | 11 | 0.00 |
![]() | 0 | 1 | 38 | 38 | 0 | 0.00 |
![]() | 0 | 3 | 12 | 14 | 1 | 0.00 |
![]() | 0 | 2 | 19 | 26 | 9 | 0.00 |
![]() | 0 | 1 | 37 | 37 | 0 | 0.00 |
![]() | 0 | 1 | 36 | 36 | 0 | 0.00 |
![]() | 0 | 1 | 36 | 36 | 0 | 0.00 |
![]() | 0 | 2 | 17 | 27 | 13 | 0.00 |
![]() | 0 | 2 | 17 | 23 | 7 | 0.00 |
![]() | 0 | 1 | 34 | 34 | 0 | 0.00 |
![]() | 0 | 2 | 17 | 17 | 0 | 0.00 |
![]() | 0 | 1 | 33 | 33 | 0 | 0.00 |
![]() | 0 | 2 | 16 | 17 | 1 | 0.00 |
![]() | 0 | 4 | 8 | 8 | 0 | 0.00 |
![]() | 0 | 10 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 15 | 26 | 14 | 0.00 |
![]() | 0 | 9 | 3 | 7 | 1 | 0.00 |
![]() | 0 | 6 | 5 | 6 | 0 | 0.00 |
![]() | 0 | 3 | 10 | 14 | 3 | 0.00 |
![]() | 0 | 2 | 15 | 19 | 5 | 0.00 |
![]() | 0 | 1 | 29 | 29 | 0 | 0.00 |
![]() | 0 | 1 | 29 | 29 | 0 | 0.00 |
![]() | 0 | 2 | 14 | 20 | 7 | 0.00 |
![]() | 0 | 1 | 28 | 28 | 0 | 0.00 |
![]() | 0 | 1 | 28 | 28 | 0 | 0.00 |
![]() | 0 | 1 | 28 | 28 | 0 | 0.00 |
![]() | 0 | 1 | 28 | 28 | 0 | 0.00 |
![]() | 0 | 4 | 7 | 20 | 8 | 0.00 |
![]() | 0 | 3 | 9 | 14 | 6 | 0.00 |
![]() | 0 | 9 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 10 | 2 | 6 | 1 | 0.00 |
![]() | 0 | 2 | 13 | 19 | 7 | 0.00 |
![]() | 0 | 9 | 2 | 5 | 0 | 0.00 |
![]() | 0 | 2 | 13 | 20 | 9 | 0.00 |
![]() | 0 | 1 | 26 | 26 | 0 | 0.00 |
![]() | 0 | 3 | 8 | 21 | 10 | 0.00 |
![]() | 0 | 2 | 12 | 15 | 3 | 0.00 |
![]() | 0 | 1 | 25 | 25 | 0 | 0.00 |
![]() | 0 | 2 | 12 | 14 | 2 | 0.00 |
![]() | 0 | 1 | 25 | 25 | 0 | 0.00 |
![]() | 0 | 2 | 12 | 16 | 5 | 0.00 |
![]() | 0 | 9 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 4 | 6 | 8 | 2 | 0.00 |
![]() | 0 | 9 | 2 | 5 | 1 | 0.00 |
![]() | 0 | 9 | 2 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 11 | 14 | 3 | 0.00 |
![]() | 0 | 3 | 7 | 10 | 2 | 0.00 |
![]() | 0 | 1 | 22 | 22 | 0 | 0.00 |
![]() | 0 | 5 | 4 | 7 | 1 | 0.00 |
![]() | 0 | 6 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 1 | 20 | 20 | 0 | 0.00 |
![]() | 0 | 1 | 20 | 20 | 0 | 0.00 |
![]() | 0 | 1 | 20 | 20 | 0 | 0.00 |
![]() | 0 | 2 | 10 | 17 | 9 | 0.00 |
![]() | 0 | 2 | 10 | 10 | 0 | 0.00 |
![]() | 0 | 1 | 20 | 20 | 0 | 0.00 |
![]() | 0 | 2 | 9 | 10 | 0 | 0.00 |
![]() | 0 | 9 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 6 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 3 | 6 | 7 | 1 | 0.00 |
![]() | 0 | 5 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 8 | 9 | 0 | 0.00 |
![]() | 0 | 4 | 4 | 10 | 3 | 0.00 |
![]() | 0 | 1 | 16 | 16 | 0 | 0.00 |
![]() | 0 | 1 | 16 | 16 | 0 | 0.00 |
![]() | 0 | 1 | 16 | 16 | 0 | 0.00 |
![]() | 0 | 1 | 15 | 15 | 0 | 0.00 |
![]() | 0 | 1 | 15 | 15 | 0 | 0.00 |
![]() | 0 | 1 | 15 | 15 | 0 | 0.00 |
![]() | 0 | 2 | 7 | 12 | 6 | 0.00 |
![]() | 0 | 1 | 15 | 15 | 0 | 0.00 |
![]() | 0 | 3 | 5 | 5 | 0 | 0.00 |
![]() | 0 | 1 | 15 | 15 | 0 | 0.00 |
![]() | 0 | 1 | 14 | 14 | 0 | 0.00 |
![]() | 0 | 2 | 7 | 9 | 2 | 0.00 |
![]() | 0 | 4 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 6 | 8 | 2 | 0.00 |
![]() | 0 | 1 | 13 | 13 | 0 | 0.00 |
![]() | 0 | 1 | 13 | 13 | 0 | 0.00 |
![]() | 0 | 1 | 13 | 13 | 0 | 0.00 |
![]() | 0 | 1 | 13 | 13 | 0 | 0.00 |
![]() | 0 | 1 | 13 | 13 | 0 | 0.00 |
![]() | 0 | 2 | 6 | 7 | 0 | 0.00 |
![]() | 0 | 1 | 13 | 13 | 0 | 0.00 |
![]() | 0 | 1 | 12 | 12 | 0 | 0.00 |
![]() | 0 | 1 | 12 | 12 | 0 | 0.00 |
![]() | 0 | 4 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 12 | 12 | 0 | 0.00 |
![]() | 0 | 1 | 11 | 11 | 0 | 0.00 |
![]() | 0 | 1 | 11 | 11 | 0 | 0.00 |
![]() | 0 | 1 | 11 | 11 | 0 | 0.00 |
![]() | 0 | 4 | 2 | 4 | 0 | 0.00 |
![]() | 0 | 1 | 11 | 11 | 0 | 0.00 |
![]() | 0 | 1 | 11 | 11 | 0 | 0.00 |
![]() | 0 | 4 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 11 | 11 | 0 | 0.00 |
![]() | 0 | 1 | 11 | 11 | 0 | 0.00 |
![]() | 0 | 1 | 10 | 10 | 0 | 0.00 |
![]() | 0 | 1 | 10 | 10 | 0 | 0.00 |
![]() | 0 | 2 | 5 | 6 | 1 | 0.00 |
![]() | 0 | 1 | 9 | 9 | 0 | 0.00 |
![]() | 0 | 3 | 3 | 4 | 1 | 0.00 |
![]() | 0 | 2 | 4 | 6 | 2 | 0.00 |
![]() | 0 | 2 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 1 | 8 | 8 | 0 | 0.00 |
![]() | 0 | 2 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 4 | 6 | 2 | 0.00 |
![]() | 0 | 2 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 3 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 1 | 7 | 7 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 4 | 0 | 0.00 |
![]() ![]() select d.data_emissao dataEmissao, d.key, d.data->'nfe'->'infNFe'->'ide'->>'nnf' numero, item.produto -> 'prod' ->> 'cprod' codigoProduto, item.produto -> 'prod' ->> 'xprod' descricaoProduto, item.produto -> 'prod' ->> 'ncm' ncm, item.produto -> 'prod' ->> 'cfop' cfop, cast(item.produto -> 'imposto' -> 'icms' -> 'icms00' ->> 'vicms' as double precision ) valorIcms from document d, jsonb_array_elements(d.data -> 'nfe' -> 'infNFe' -> 'det') WITH ORDINALITY item(produto) where cnpj_issuer = ? and type in ('NFE_4_0','NFE_3_1') and item.produto -> 'prod' ->> 'ncm' in (?, ?) and item.produto -> 'prod' ->> 'cfop' in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 3 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 4 | 1 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 6 | 6 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 5 | 5 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 5 | 5 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 3 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 1 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 1 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 1 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 1 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 1 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 1 | 4 | 4 | 0 | 0.00 |
![]() | 0 | 2 | 2 | 2 | 0 | 0.00 |
![]() | 0 | 1 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 3 | 3 | 0 | 0.00 |
![]() | 0 | 1 | 2 | 2 | 0 | 0.00 |
Request | % of cumulative time | Hits | Mean time (ms) | Max time (ms) | Standard deviation | % of cumulative cpu time | Mean cpu time (ms) | Mean allocated Kb | % of system error | Mean hits sql | Mean time sql (ms) |
---|---|---|---|---|---|---|---|---|---|---|---|
spring global | 100 | 125,813 | 57 | 241,396 | 1,417 | 100 | 2 | 1,136 | 0.00 | 1 | 42 |
spring warning | 26 | 1,288 | 1,517 | 241,396 | 10,460 | 3 | 7 | 3,916 | 0.00 | 2 | 1,419 |
spring severe | 24 | 255 | 6,861 | 160,702 | 19,004 | 3 | 50 | 10,431 | 0.00 | 74 | 3,311 |
Error | % of cumulative time | Hits | Mean time (ms) | Max time (ms) | Standard deviation | % of cumulative cpu time | Mean cpu time (ms) | Mean allocated Kb |
---|---|---|---|---|---|---|---|---|
Error404 | 4 | 28 | 1 | 4 | 0 | 57 | 1 | 310 |
Error | % of cumulative time | Hits | Mean time (ms) | Max time (ms) | Standard deviation | % of cumulative cpu time | Mean cpu time (ms) | Mean allocated Kb |
---|---|---|---|---|---|---|---|---|
Error404 | 4 | 28 | 1 | 4 | 0 | 57 | 1 | 310 |
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 | 4 | 3 | 17 | 47 | 25 | 15 | 3 | 546 |
Error400 | 91 | 3 | 356 | 1,067 | 615 | 26 | 5 | 700 |
Date | Request | User | Error |
---|---|---|---|
9/10/25, 12:39:56 PM | /favicon.ico GET | Error404 | |
9/10/25, 12:48:27 PM | /favicon.ico GET | Error404 | |
9/10/25, 12:51:45 PM | /api/document/04402277000444/analise-representatividade-consolidada POST | UsuarioAutenticadoParaServicos{id=3794, email='fares.mady@bicworld.com'} |
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 at java.base/java.time.format.DateTimeFormatter.parseResolved0(Unknown Source) at java.base/java.time.format.DateTimeFormatter.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at br.com.revizia.documentapi.util.DateUtil.findPeriodByQueryTypeAndPeriod(DateUtil.java:75) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidada(DocumentService.java:6799) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidadaGrafico(DocumentService.java:6756) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.analiseRepresentatividadeConsolidadaGrafico(<generated>) at br.com.revizia.documentapi.controller.DocumentController.analiseRepresentatividadeConsolidada(DocumentController.java:771) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.analiseRepresentatividadeConsolidada(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ... 102 more org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 |
9/10/25, 12:53:33 PM | /robots.txt GET | Error404 | |
9/10/25, 1:13:52 PM | /api/document/11516257003213/v2/nfe POST | UsuarioAutenticadoParaServicos{id=4063, email='comercial03@loftystyle.com.br'} | Error400 |
9/10/25, 1:15:05 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:16:44 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:27:49 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:33:43 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:45:46 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:46:19 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:47:48 PM | /api/etiqueta/listar POST | Error400 | |
9/10/25, 1:50:55 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:55:40 PM | /robots.txt GET | Error404 | |
9/10/25, 1:55:51 PM | /api/document/30250781000133/analise-representatividade-consolidada POST | UsuarioAutenticadoParaServicos{id=469, email='ct.luan@ifact.com.br'} |
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 at java.base/java.time.format.DateTimeFormatter.parseResolved0(Unknown Source) at java.base/java.time.format.DateTimeFormatter.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at br.com.revizia.documentapi.util.DateUtil.findPeriodByQueryTypeAndPeriod(DateUtil.java:75) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidada(DocumentService.java:6799) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidadaGrafico(DocumentService.java:6756) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.analiseRepresentatividadeConsolidadaGrafico(<generated>) at br.com.revizia.documentapi.controller.DocumentController.analiseRepresentatividadeConsolidada(DocumentController.java:771) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.analiseRepresentatividadeConsolidada(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ... 102 more org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 |
9/10/25, 1:59:26 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:59:33 PM | /favicon.ico GET | Error404 | |
9/10/25, 1:59:39 PM | /api/etiqueta/listar POST | Error400 | |
9/10/25, 2:00:04 PM | /api/document/30250781000133/analise-representatividade-consolidada POST | UsuarioAutenticadoParaServicos{id=469, email='ct.luan@ifact.com.br'} |
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 at java.base/java.time.format.DateTimeFormatter.parseResolved0(Unknown Source) at java.base/java.time.format.DateTimeFormatter.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at br.com.revizia.documentapi.util.DateUtil.findPeriodByQueryTypeAndPeriod(DateUtil.java:75) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidada(DocumentService.java:6799) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidadaGrafico(DocumentService.java:6756) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.analiseRepresentatividadeConsolidadaGrafico(<generated>) at br.com.revizia.documentapi.controller.DocumentController.analiseRepresentatividadeConsolidada(DocumentController.java:771) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.analiseRepresentatividadeConsolidada(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ... 102 more org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 |
9/10/25, 2:05:25 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:12:37 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:19:48 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:20:58 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:23:57 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:24:05 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:24:51 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:25:30 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:51:50 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:55:54 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:56:49 PM | /robots.txt GET | Error404 | |
9/10/25, 2:57:02 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:58:11 PM | /favicon.ico GET | Error404 | |
9/10/25, 2:59:19 PM | /favicon.ico GET | Error404 | |
9/10/25, 3:00:45 PM | /favicon.ico GET | Error404 |
Error | Hits |
---|---|
ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | 23 |
Date | Request | User | Error |
---|---|---|---|
9/10/25, 12:27:22 PM | /api/reports/nfe/35250923820026000858550010000118021483468876 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} | WARN n.s.j.engine.export.PdfGlyphRenderer - Unpatched iText found, cannot use glyph rendering |
9/10/25, 12:30:28 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy341.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy247.findAll(Unknown Source) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentNfe(DocumentNfeViewQueryService.java:209) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentsWithData(DocumentNfeViewQueryService.java:74) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$FastClassBySpringCGLIB$$3c6d94cf.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$EnhancerBySpringCGLIB$$56a1a2.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsNFEV2(DocumentController.java:446) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsNFEV2(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@17a99ede on thread XNIO-1 task-7, stack trace follows | ||
9/10/25, 12:32:49 PM | /api/reports/nfe/35250923820026000858550010000118261309038197 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The reference to entity "A" must end with the ';' delimiter.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:32:49 PM | /api/reports/nfe/35250923820026000858550010000118261309038197 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The reference to entity "A" must end with the ';' delimiter.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:32:50 PM | /api/reports/nfe/35250923820026000858550010000118261309038197 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The reference to entity "A" must end with the ';' delimiter.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:33:32 PM | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@6b6b57c9 (This connection has been closed.). Possibly consider using a shorter maxLifetime value. | ||
9/10/25, 12:35:39 PM | /api/reports/nfe/35250923820026000858550010000118521508123950 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:35:39 PM | /api/reports/nfe/35250923820026000858550010000118521508123950 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:35:39 PM | /api/reports/nfe/35250923820026000858550010000118521508123950 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:37:34 PM | /api/reports/nfe/35250923820026000858550010000118701047587480 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:37:34 PM | /api/reports/nfe/35250923820026000858550010000118701047587480 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:37:35 PM | /api/reports/nfe/35250923820026000858550010000118701047587480 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:42:36 PM | /api/reports/nfe/35250923820026000858550010000119191543777015 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:42:36 PM | /api/reports/nfe/35250923820026000858550010000119191543777015 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:42:36 PM | /api/reports/nfe/35250923820026000858550010000119191543777015 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:44:02 PM | /api/reports/nfe/35250968400449001071550010008303041574744380 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:44:22 PM | /api/reports/nfe/35250968400449001071550010008303231800289150 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The reference to entity "S" must end with the ';' delimiter.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:45:40 PM | /api/reports/nfe/35250917324331000775550010000134181843565893 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2615) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:836) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:296) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:123) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. |
9/10/25, 12:51:45 PM |
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 at java.base/java.time.format.DateTimeFormatter.parseResolved0(Unknown Source) at java.base/java.time.format.DateTimeFormatter.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at br.com.revizia.documentapi.util.DateUtil.findPeriodByQueryTypeAndPeriod(DateUtil.java:75) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidada(DocumentService.java:6799) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidadaGrafico(DocumentService.java:6756) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.analiseRepresentatividadeConsolidadaGrafico(<generated>) at br.com.revizia.documentapi.controller.DocumentController.analiseRepresentatividadeConsolidada(DocumentController.java:771) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.analiseRepresentatividadeConsolidada(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ... 102 common frames omitted ERROR io.undertow.request - UT005023: Exception handling request to /api/document/04402277000444/analise-representatividade-consolidada | ||
9/10/25, 1:10:18 PM | /api/reports/nfe/42250901625195001019550010001629191573765891 GET |
org.xml.sax.SAXParseException: The reference to entity "A" must end with the ';' delimiter.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | |
9/10/25, 1:10:22 PM | /api/reports/nfe/42250901625195001019550010001629191573765891 GET |
org.xml.sax.SAXParseException: The reference to entity "A" must end with the ';' delimiter.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | |
9/10/25, 1:13:52 PM | /api/document/11516257003213/v2/nfe POST | UsuarioAutenticadoParaServicos{id=4063, email='comercial03@loftystyle.com.br'} | WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolved [org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: Named parameter not bound : valueUntil; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: Named parameter not bound : valueUntil] |
9/10/25, 1:16:19 PM | /api/reports/nfe/35250912450140000221550010000072721000193920 GET |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:336) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:267) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | |
9/10/25, 1:16:19 PM | /api/reports/nfe/35250912450140000221550010000072721000193920 GET |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | |
9/10/25, 1:16:19 PM | /api/reports/nfe/35250912450140000221550010000072721000193920 GET |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | |
9/10/25, 1:16:19 PM | /api/reports/nfe/35250912450140000221550010000072721000193920 GET |
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:461) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:420) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageBreak(JRVerticalFiller.java:2360) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBreak(JRVerticalFiller.java:2449) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2697) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:836) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:296) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:123) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | |
9/10/25, 1:30:32 PM | WARN o.a.poi.xssf.usermodel.XSSFWorkbook - Sheet 'Exportacao_NFe_Recebidas_Revizia' will be added with a trimmed name 'Exportacao_NFe_Recebidas_Revizi' for MS Excel compliance. | ||
9/10/25, 1:30:33 PM | WARN b.c.r.documentapi.service.AwsService - >> AWS: Bucket [app-document-import-prod-v2] Filename [92044.zip] | ||
9/10/25, 1:47:48 PM | /api/etiqueta/listar POST | WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolved [java.lang.IllegalArgumentException: JWT String argument cannot be null or empty.] | |
9/10/25, 1:54:14 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.query.JpaQueryExecution$ExistsExecution.doExecute(JpaQueryExecution.java:291) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy344.existsByCnpjAndStatusIn(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy301.existsByCnpjAndStatusIn(Unknown Source) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.getNfeStatus(AnaliseCarregamentoDocumentosImpl.java:120) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.consultarDocumentosCarregados(AnaliseCarregamentoDocumentosImpl.java:63) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl$$FastClassBySpringCGLIB$$aa3f78ba.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl$$EnhancerBySpringCGLIB$$5f201c6e.consultarDocumentosCarregados(<generated>) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController.consultarCarregamentos(ProcessamentoCarregamentoDocumentosController.java:31) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController$$FastClassBySpringCGLIB$$573eb675.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController$$EnhancerBySpringCGLIB$$5fa8c27f.consultarCarregamentos(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@18eaf5b2 on thread XNIO-1 task-6, stack trace follows | ||
9/10/25, 1:54:15 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338) at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2141) at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1163) at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:173) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1581) at jdk.internal.reflect.GeneratedMethodAccessor394.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:409) at com.sun.proxy.$Proxy388.getSingleResult(Unknown Source) at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy393.existsDocumentsByCnpjGroup(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy202.existsDocumentsByCnpjGroup(Unknown Source) at br.com.revizia.documentapi.service.DocumentService.checaSeExisteDocumentosPorCnpjEGrupo(DocumentService.java:7955) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.checaSeExisteDocumentosPorCnpjEGrupo(<generated>) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.getDocumentStatus(AnaliseCarregamentoDocumentosImpl.java:129) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.lambda$consultarDocumentosCarregados$0(AnaliseCarregamentoDocumentosImpl.java:84) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.base/java.util.stream.ForEachOps$ForEachTask.compute(Unknown Source) at java.base/java.util.concurrent.CountedCompleter.exec(Unknown Source) at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@5cccae9 on thread ForkJoinPool.commonPool-worker-13, stack trace follows | ||
9/10/25, 1:55:25 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.query.JpaQueryExecution$ExistsExecution.doExecute(JpaQueryExecution.java:291) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy344.existsByCnpjAndStatusIn(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy301.existsByCnpjAndStatusIn(Unknown Source) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.getNfeStatus(AnaliseCarregamentoDocumentosImpl.java:120) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.consultarDocumentosCarregados(AnaliseCarregamentoDocumentosImpl.java:63) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl$$FastClassBySpringCGLIB$$aa3f78ba.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl$$EnhancerBySpringCGLIB$$5f201c6e.consultarDocumentosCarregados(<generated>) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController.consultarCarregamentos(ProcessamentoCarregamentoDocumentosController.java:31) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController$$FastClassBySpringCGLIB$$573eb675.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController$$EnhancerBySpringCGLIB$$5fa8c27f.consultarCarregamentos(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@50621905 on thread XNIO-1 task-19, stack trace follows | ||
9/10/25, 1:55:26 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338) at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2141) at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1163) at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:173) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1581) at jdk.internal.reflect.GeneratedMethodAccessor394.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:409) at com.sun.proxy.$Proxy388.getSingleResult(Unknown Source) at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy393.existsDocumentsByCnpjGroup(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy202.existsDocumentsByCnpjGroup(Unknown Source) at br.com.revizia.documentapi.service.DocumentService.checaSeExisteDocumentosPorCnpjEGrupo(DocumentService.java:7955) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.checaSeExisteDocumentosPorCnpjEGrupo(<generated>) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.getDocumentStatus(AnaliseCarregamentoDocumentosImpl.java:129) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.lambda$consultarDocumentosCarregados$0(AnaliseCarregamentoDocumentosImpl.java:84) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.base/java.util.stream.ForEachOps$ForEachTask.compute(Unknown Source) at java.base/java.util.concurrent.CountedCompleter.exec(Unknown Source) at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@7e8b17c6 on thread ForkJoinPool.commonPool-worker-15, stack trace follows | ||
9/10/25, 1:55:51 PM |
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 at java.base/java.time.format.DateTimeFormatter.parseResolved0(Unknown Source) at java.base/java.time.format.DateTimeFormatter.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at br.com.revizia.documentapi.util.DateUtil.findPeriodByQueryTypeAndPeriod(DateUtil.java:75) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidada(DocumentService.java:6799) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidadaGrafico(DocumentService.java:6756) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.analiseRepresentatividadeConsolidadaGrafico(<generated>) at br.com.revizia.documentapi.controller.DocumentController.analiseRepresentatividadeConsolidada(DocumentController.java:771) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.analiseRepresentatividadeConsolidada(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ... 102 common frames omitted ERROR io.undertow.request - UT005023: Exception handling request to /api/document/30250781000133/analise-representatividade-consolidada | ||
9/10/25, 1:57:39 PM | /api/document/11516257000974/v2/nfse POST |
org.springframework.web.reactive.function.client.WebClientResponseException$InternalServerError: 500 Internal Server Error from GET https://core-api.revizia.app/api/integracao/ibge/cidades?ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308
at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:201) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): |_ checkpoint ⇢ 500 from GET https://core-api.revizia.app/api/integracao/ibge/cidades?ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308 [DefaultWebClient] Stack trace: at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:201) at org.springframework.web.reactive.function.client.DefaultClientResponse.lambda$createException$1(DefaultClientResponse.java:206) at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100) at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onNext(FluxDefaultIfEmpty.java:92) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.onNext(FluxContextStart.java:96) at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:330) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1782) at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:152) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:252) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:374) at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:373) at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:429) at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:655) at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:96) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1533) at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1282) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1329) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:501) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:440) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Unknown Source) Suppressed: java.lang.Exception: #block terminated with an error at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) at reactor.core.publisher.Mono.block(Mono.java:1680) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl.buscarCidades(CoreApiServiceImpl.java:242) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl$$FastClassBySpringCGLIB$$15a0a3e6.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.retry.interceptor.RetryOperationsInterceptor$1.doWithRetry(RetryOperationsInterceptor.java:91) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:287) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:180) at org.springframework.retry.interceptor.RetryOperationsInterceptor.invoke(RetryOperationsInterceptor.java:115) at org.springframework.retry.annotation.AnnotationAwareRetryOperationsInterceptor.invoke(AnnotationAwareRetryOperationsInterceptor.java:153) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl$$EnhancerBySpringCGLIB$$4ab5e8d9.buscarCidades(<generated>) at br.com.revizia.documentapi.service.DocumentService.retrieveCityMap(DocumentService.java:7977) at br.com.revizia.documentapi.service.DocumentService.findDocumentNfseDto(DocumentService.java:7960) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.findDocumentNfseDto(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getNfse(DocumentController.java:822) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getNfse(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor932.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR b.c.r.d.i.c.s.i.CoreApiServiceImpl - Erro ao consultar email e nome de usuarios do core-api. Tentativas esgotadas. | |
9/10/25, 1:57:45 PM | /api/document/11516257000974/v2/nfse POST |
org.springframework.web.reactive.function.client.WebClientResponseException$InternalServerError: 500 Internal Server Error from GET https://core-api.revizia.app/api/integracao/ibge/cidades?ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308
at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:201) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): |_ checkpoint ⇢ 500 from GET https://core-api.revizia.app/api/integracao/ibge/cidades?ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308 [DefaultWebClient] Stack trace: at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:201) at org.springframework.web.reactive.function.client.DefaultClientResponse.lambda$createException$1(DefaultClientResponse.java:206) at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100) at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onNext(FluxDefaultIfEmpty.java:92) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.onNext(FluxContextStart.java:96) at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:330) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1782) at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:152) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:252) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:374) at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:373) at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:429) at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:655) at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:96) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1533) at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1282) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1329) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:501) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:440) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe$1.run(AbstractEpollChannel.java:388) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Unknown Source) Suppressed: java.lang.Exception: #block terminated with an error at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) at reactor.core.publisher.Mono.block(Mono.java:1680) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl.buscarCidades(CoreApiServiceImpl.java:242) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl$$FastClassBySpringCGLIB$$15a0a3e6.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.retry.interceptor.RetryOperationsInterceptor$1.doWithRetry(RetryOperationsInterceptor.java:91) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:287) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:180) at org.springframework.retry.interceptor.RetryOperationsInterceptor.invoke(RetryOperationsInterceptor.java:115) at org.springframework.retry.annotation.AnnotationAwareRetryOperationsInterceptor.invoke(AnnotationAwareRetryOperationsInterceptor.java:153) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl$$EnhancerBySpringCGLIB$$4ab5e8d9.buscarCidades(<generated>) at br.com.revizia.documentapi.service.DocumentService.retrieveCityMap(DocumentService.java:7977) at br.com.revizia.documentapi.service.DocumentService.findDocumentNfseDto(DocumentService.java:7960) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.findDocumentNfseDto(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getNfse(DocumentController.java:822) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getNfse(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor932.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR b.c.r.d.i.c.s.i.CoreApiServiceImpl - Erro ao consultar email e nome de usuarios do core-api. Tentativas esgotadas. | |
9/10/25, 1:57:48 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.query.JpaQueryExecution$ExistsExecution.doExecute(JpaQueryExecution.java:291) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy344.existsByCnpjAndStatusIn(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy301.existsByCnpjAndStatusIn(Unknown Source) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.getNfeStatus(AnaliseCarregamentoDocumentosImpl.java:120) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.consultarDocumentosCarregados(AnaliseCarregamentoDocumentosImpl.java:63) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl$$FastClassBySpringCGLIB$$aa3f78ba.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl$$EnhancerBySpringCGLIB$$5f201c6e.consultarDocumentosCarregados(<generated>) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController.consultarCarregamentos(ProcessamentoCarregamentoDocumentosController.java:31) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController$$FastClassBySpringCGLIB$$573eb675.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.controller.ProcessamentoCarregamentoDocumentosController$$EnhancerBySpringCGLIB$$5fa8c27f.consultarCarregamentos(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@61198452 on thread XNIO-1 task-1, stack trace follows | ||
9/10/25, 1:57:48 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338) at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2141) at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1163) at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:173) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1581) at jdk.internal.reflect.GeneratedMethodAccessor394.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:409) at com.sun.proxy.$Proxy388.getSingleResult(Unknown Source) at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy393.existsDocumentsByCnpjGroup(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy202.existsDocumentsByCnpjGroup(Unknown Source) at br.com.revizia.documentapi.service.DocumentService.checaSeExisteDocumentosPorCnpjEGrupo(DocumentService.java:7955) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.checaSeExisteDocumentosPorCnpjEGrupo(<generated>) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.getDocumentStatus(AnaliseCarregamentoDocumentosImpl.java:129) at br.com.revizia.documentapi.v2.processamentocarregamentodedados.service.impl.AnaliseCarregamentoDocumentosImpl.lambda$consultarDocumentosCarregados$0(AnaliseCarregamentoDocumentosImpl.java:84) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.base/java.util.stream.ForEachOps$ForEachTask.compute(Unknown Source) at java.base/java.util.concurrent.CountedCompleter.exec(Unknown Source) at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@60b9c0e2 on thread ForkJoinPool.commonPool-worker-5, stack trace follows | ||
9/10/25, 1:58:37 PM | /api/document/11516257000974/v2/nfse POST |
org.springframework.web.reactive.function.client.WebClientResponseException$InternalServerError: 500 Internal Server Error from GET https://core-api.revizia.app/api/integracao/ibge/cidades?ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308
at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:201) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): |_ checkpoint ⇢ 500 from GET https://core-api.revizia.app/api/integracao/ibge/cidades?ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308 [DefaultWebClient] Stack trace: at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:201) at org.springframework.web.reactive.function.client.DefaultClientResponse.lambda$createException$1(DefaultClientResponse.java:206) at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100) at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onNext(FluxDefaultIfEmpty.java:92) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.onNext(FluxContextStart.java:96) at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:330) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1782) at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:152) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:252) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:374) at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:373) at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:429) at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:655) at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:96) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1533) at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1282) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1329) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:501) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:440) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Unknown Source) Suppressed: java.lang.Exception: #block terminated with an error at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) at reactor.core.publisher.Mono.block(Mono.java:1680) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl.buscarCidades(CoreApiServiceImpl.java:242) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl$$FastClassBySpringCGLIB$$15a0a3e6.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.retry.interceptor.RetryOperationsInterceptor$1.doWithRetry(RetryOperationsInterceptor.java:91) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:287) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:180) at org.springframework.retry.interceptor.RetryOperationsInterceptor.invoke(RetryOperationsInterceptor.java:115) at org.springframework.retry.annotation.AnnotationAwareRetryOperationsInterceptor.invoke(AnnotationAwareRetryOperationsInterceptor.java:153) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl$$EnhancerBySpringCGLIB$$4ab5e8d9.buscarCidades(<generated>) at br.com.revizia.documentapi.service.DocumentService.retrieveCityMap(DocumentService.java:7977) at br.com.revizia.documentapi.service.DocumentService.findDocumentNfseDto(DocumentService.java:7960) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.findDocumentNfseDto(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getNfse(DocumentController.java:822) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getNfse(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor932.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR b.c.r.d.i.c.s.i.CoreApiServiceImpl - Erro ao consultar email e nome de usuarios do core-api. Tentativas esgotadas. | |
9/10/25, 1:58:39 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy341.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy247.findAll(Unknown Source) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentNfe(DocumentNfeViewQueryService.java:209) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentsWithData(DocumentNfeViewQueryService.java:74) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$FastClassBySpringCGLIB$$3c6d94cf.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$EnhancerBySpringCGLIB$$56a1a2.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsNFEV2(DocumentController.java:446) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsNFEV2(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor446.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@61198452 on thread XNIO-1 task-1, stack trace follows | ||
9/10/25, 1:59:39 PM | /api/etiqueta/listar POST | WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolved [java.lang.IllegalArgumentException: JWT String argument cannot be null or empty.] | |
9/10/25, 2:00:04 PM |
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.time.format.DateTimeParseException: Text 'null-01' could not be parsed at index 0 at java.base/java.time.format.DateTimeFormatter.parseResolved0(Unknown Source) at java.base/java.time.format.DateTimeFormatter.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at java.base/java.time.YearMonth.parse(Unknown Source) at br.com.revizia.documentapi.util.DateUtil.findPeriodByQueryTypeAndPeriod(DateUtil.java:75) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidada(DocumentService.java:6799) at br.com.revizia.documentapi.service.DocumentService.analiseRepresentatividadeConsolidadaGrafico(DocumentService.java:6756) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.analiseRepresentatividadeConsolidadaGrafico(<generated>) at br.com.revizia.documentapi.controller.DocumentController.analiseRepresentatividadeConsolidada(DocumentController.java:771) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.analiseRepresentatividadeConsolidada(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ... 102 common frames omitted ERROR io.undertow.request - UT005023: Exception handling request to /api/document/30250781000133/analise-representatividade-consolidada | ||
9/10/25, 2:00:15 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy341.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy247.findAll(Unknown Source) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentNfe(DocumentNfeViewQueryService.java:209) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentsWithData(DocumentNfeViewQueryService.java:74) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$FastClassBySpringCGLIB$$3c6d94cf.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$EnhancerBySpringCGLIB$$56a1a2.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsNFEV2(DocumentController.java:446) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsNFEV2(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor446.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@7d81697c on thread XNIO-1 task-7, stack trace follows | ||
9/10/25, 2:02:17 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy354.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy246.findAll(Unknown Source) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService.findDocumentNfe(DocumentNfeCanhotoViewQueryService.java:198) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService.findDocumentsWithData(DocumentNfeCanhotoViewQueryService.java:66) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService$$FastClassBySpringCGLIB$$d151a267.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService$$EnhancerBySpringCGLIB$$77cc096a.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsNFECanhoto(DocumentController.java:455) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsNFECanhoto(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor874.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@41944c5b on thread XNIO-1 task-6, stack trace follows | ||
9/10/25, 2:08:35 PM | /api/document/05790721000166/consolidacao-cnpj POST | UsuarioAutenticadoParaServicos{id=469, email='ct.luan@ifact.com.br'} |
org.influxdb.InfluxDBIOException: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8096
at org.influxdb.impl.InfluxDBImpl.ping(InfluxDBImpl.java:405) at br.com.revizia.documentapi.metrics.MetricsService.getClient(MetricsService.java:53) at br.com.revizia.documentapi.metrics.MetricsService.writeMetrics(MetricsService.java:81) at br.com.revizia.documentapi.service.DocumentService.consolidarCnpjPorTipoPeriodo(DocumentService.java:5457) at br.com.revizia.documentapi.service.DocumentService.consolidarCnpjPorTipo(DocumentService.java:4435) at br.com.revizia.documentapi.service.DocumentService.consolidacaoCnpj(DocumentService.java:4300) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.consolidacaoCnpj(<generated>) at br.com.revizia.documentapi.controller.DocumentController.consolidacaoCnpj(DocumentController.java:607) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.consolidacaoCnpj(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8096 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:265) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:183) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88) at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:169) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at org.influxdb.impl.BasicAuthInterceptor.intercept(BasicAuthInterceptor.java:22) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at org.influxdb.impl.GzipRequestInterceptor.intercept(GzipRequestInterceptor.java:45) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:152) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229) at okhttp3.RealCall.execute(RealCall.java:81) at retrofit2.OkHttpCall.execute(OkHttpCall.java:204) at org.influxdb.impl.InfluxDBImpl.ping(InfluxDBImpl.java:391) ... 149 common frames omitted Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.base/java.net.SocksSocketImpl.connect(Unknown Source) at java.base/java.net.Socket.connect(Unknown Source) at okhttp3.internal.platform.Platform.connectSocket(Platform.java:130) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:263) ... 178 common frames omitted ERROR b.c.r.d.metrics.MetricsService - Erro ao criar conexão com influxdb |
9/10/25, 2:08:36 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1581) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:111) at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy324.findByTipoConsolidacao(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy208.findByTipoConsolidacao(Unknown Source) at br.com.revizia.documentapi.service.DocumentService.consolidarCnpjPorTipoPeriodo(DocumentService.java:4469) at br.com.revizia.documentapi.service.DocumentService.consolidarCnpjPorTipo(DocumentService.java:4435) at br.com.revizia.documentapi.service.DocumentService.consolidacaoCnpj(DocumentService.java:4300) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.consolidacaoCnpj(<generated>) at br.com.revizia.documentapi.controller.DocumentController.consolidacaoCnpj(DocumentController.java:607) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.consolidacaoCnpj(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@41944c5b on thread XNIO-1 task-6, stack trace follows | ||
9/10/25, 2:12:52 PM | /api/cte/credito-pis-cofins-frete-insumo-aliquota-zero/10920714000171/period?dataInicio=2022-09-04T00:00&dataFim=2022-09-04T23:59:59&page=0&size=1000 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@781e978d (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:12:52 PM | /api/cte/credito-pis-cofins-frete-insumo-aliquota-zero/10920714000171/period?dataInicio=2022-09-04T00:00&dataFim=2022-09-04T23:59:59&page=0&size=1000 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@60b9c0e2 (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:12:52 PM | /api/cte/credito-pis-cofins-frete-insumo-aliquota-zero/10920714000171/period?dataInicio=2022-09-04T00:00&dataFim=2022-09-04T23:59:59&page=0&size=1000 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@61198452 (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:12:52 PM | /api/cte/credito-pis-cofins-frete-insumo-aliquota-zero/10920714000171/period?dataInicio=2022-09-03T00:00&dataFim=2022-09-03T23:59:59&page=0&size=1000 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@50621905 (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:12:52 PM | /api/cte/credito-pis-cofins-frete-insumo-aliquota-zero/10920714000171/period?dataInicio=2022-09-03T00:00&dataFim=2022-09-03T23:59:59&page=0&size=1000 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@7d81697c (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:12:52 PM | /api/cte/credito-pis-cofins-frete-insumo-aliquota-zero/10920714000171/period?dataInicio=2022-09-07T00:00&dataFim=2022-09-07T23:59:59&page=0&size=1000 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@3e95a039 (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:12:52 PM | /api/cte/credito-pis-cofins-frete-insumo-aliquota-zero/10920714000171/period?dataInicio=2022-09-03T00:00&dataFim=2022-09-03T23:59:59&page=0&size=1000 GET | UsuarioAutenticadoParaServicos{id=3, email='revizia-cron-job@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@4c3519e5 (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:16:05 PM | /api/document/07704872000180/documentos/quantidade POST | UsuarioAutenticadoParaServicos{id=2, email='documentos@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@6707c7ff (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:16:05 PM | /api/document/07704872000180/documentos/quantidade POST | UsuarioAutenticadoParaServicos{id=2, email='documentos@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@1f99c69e (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:19:37 PM | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@41944c5b (This connection has been closed.). Possibly consider using a shorter maxLifetime value. | ||
9/10/25, 2:19:38 PM | WARN o.a.poi.xssf.usermodel.XSSFWorkbook - Sheet 'Exportacao_NFe_Recebidas_Revizia' will be added with a trimmed name 'Exportacao_NFe_Recebidas_Revizi' for MS Excel compliance. | ||
9/10/25, 2:19:38 PM | WARN b.c.r.documentapi.service.AwsService - >> AWS: Bucket [app-document-import-prod-v2] Filename [92049.zip] | ||
9/10/25, 2:20:01 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy387.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy250.findAll(Unknown Source) at br.com.revizia.documentapi.service.impl.DocumentCteViewQueryService.findDocuments(DocumentCteViewQueryService.java:166) at br.com.revizia.documentapi.service.impl.DocumentCteViewQueryService.findDocumentsWithData(DocumentCteViewQueryService.java:55) at br.com.revizia.documentapi.service.impl.DocumentCteViewQueryService$$FastClassBySpringCGLIB$$d69c42f2.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.DocumentCteViewQueryService$$EnhancerBySpringCGLIB$$c319eb.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsCte(DocumentController.java:464) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsCte(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor487.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@224f6a3d on thread XNIO-1 task-15, stack trace follows | ||
9/10/25, 2:23:44 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1581) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:111) at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy324.findByTipoConsolidacao(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy208.findByTipoConsolidacao(Unknown Source) at br.com.revizia.documentapi.service.DocumentService.consolidarCnpjPorTipoPeriodo(DocumentService.java:4469) at br.com.revizia.documentapi.service.DocumentService.consolidarCnpjPorTipo(DocumentService.java:4435) at br.com.revizia.documentapi.service.DocumentService.consolidacaoCnpj(DocumentService.java:4300) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.consolidacaoCnpj(<generated>) at br.com.revizia.documentapi.controller.DocumentController.consolidacaoCnpj(DocumentController.java:607) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.consolidacaoCnpj(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@6af4527f on thread XNIO-1 task-1, stack trace follows | ||
9/10/25, 2:24:05 PM | /api/reports/nfe/23250907240641000910550040000011751000085985 GET |
org.xml.sax.SAXParseException: The entity "AMP" was referenced, but not declared.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:336) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:267) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | |
9/10/25, 2:24:11 PM | /api/reports/nfe/23250907240641000910550040000011751000085985 GET |
org.xml.sax.SAXParseException: The entity "AMP" was referenced, but not declared.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:237) at net.sf.jasperreports.engine.util.JRStyledTextParser.getStyledText(JRStyledTextParser.java:270) at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:576) at net.sf.jasperreports.engine.fill.JRFillTextElement.getTextString(JRFillTextElement.java:607) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:783) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillFrame.prepare(JRFillFrame.java:254) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:542) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:453) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:428) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:336) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:267) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:433) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:162) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:739) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1061) at br.com.revizia.documentapi.util.JasperReportUtil.generatePdfNFEDocumentByXml(JasperReportUtil.java:93) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.getBytes(GeradorPdfNfeServiceImpl.java:103) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByObjectAndDocumentType(GeradorPdfNfeServiceImpl.java:85) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:59) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR n.s.j.engine.util.JRStyledTextParser - Error parsing styled text. | |
9/10/25, 2:24:27 PM | WARN o.s.b.a.a.m.OnlyOnceLoggingDenyMeterFilter - Reached the maximum number of URI tags for 'http.client.requests'. Are you using 'uriVariables'? | ||
9/10/25, 2:31:00 PM | /api/importacao-canhoto/canhotos/205412/confirmar-upload POST | UsuarioAutenticadoParaServicos{id=3403, email='jaqueline.santos@novageracaoltda.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@6af4527f (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:31:00 PM | /api/importacao-canhoto/canhotos/205412/confirmar-upload POST | UsuarioAutenticadoParaServicos{id=3403, email='jaqueline.santos@novageracaoltda.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@68cdcd47 (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:32:32 PM | /api/document/05548796000135/v2/nfse POST |
org.springframework.web.reactive.function.client.WebClientResponseException$InternalServerError: 500 Internal Server Error from GET https://core-api.revizia.app/api/integracao/ibge/cidades?ibgeCodes=3550308&ibgeCodes=3106200&ibgeCodes=3550308&ibgeCodes=4202909&ibgeCodes=4202909&ibgeCodes=3550308&ibgeCodes=3106200&ibgeCodes=3170107&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308
at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:201) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): |_ checkpoint ⇢ 500 from GET https://core-api.revizia.app/api/integracao/ibge/cidades?ibgeCodes=3550308&ibgeCodes=3106200&ibgeCodes=3550308&ibgeCodes=4202909&ibgeCodes=4202909&ibgeCodes=3550308&ibgeCodes=3106200&ibgeCodes=3170107&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308&ibgeCodes=3550308 [DefaultWebClient] Stack trace: at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:201) at org.springframework.web.reactive.function.client.DefaultClientResponse.lambda$createException$1(DefaultClientResponse.java:206) at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100) at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onNext(FluxDefaultIfEmpty.java:92) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.onNext(FluxContextStart.java:96) at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:330) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1782) at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:152) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:252) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:374) at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:373) at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:429) at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:655) at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:96) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1533) at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1282) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1329) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:501) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:440) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe$1.run(AbstractEpollChannel.java:388) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Unknown Source) Suppressed: java.lang.Exception: #block terminated with an error at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) at reactor.core.publisher.Mono.block(Mono.java:1680) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl.buscarCidades(CoreApiServiceImpl.java:242) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl$$FastClassBySpringCGLIB$$15a0a3e6.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.retry.interceptor.RetryOperationsInterceptor$1.doWithRetry(RetryOperationsInterceptor.java:91) at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:287) at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:180) at org.springframework.retry.interceptor.RetryOperationsInterceptor.invoke(RetryOperationsInterceptor.java:115) at org.springframework.retry.annotation.AnnotationAwareRetryOperationsInterceptor.invoke(AnnotationAwareRetryOperationsInterceptor.java:153) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.integration.coreapi.service.impl.CoreApiServiceImpl$$EnhancerBySpringCGLIB$$4ab5e8d9.buscarCidades(<generated>) at br.com.revizia.documentapi.service.DocumentService.retrieveCityMap(DocumentService.java:7977) at br.com.revizia.documentapi.service.DocumentService.findDocumentNfseDto(DocumentService.java:7960) at br.com.revizia.documentapi.service.DocumentService$$FastClassBySpringCGLIB$$200e3ba5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentService$$EnhancerBySpringCGLIB$$699f7820.findDocumentNfseDto(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getNfse(DocumentController.java:822) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getNfse(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor932.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) ERROR b.c.r.d.i.c.s.i.CoreApiServiceImpl - Erro ao consultar email e nome de usuarios do core-api. Tentativas esgotadas. | |
9/10/25, 2:33:24 PM | WARN o.a.poi.xssf.usermodel.XSSFWorkbook - Sheet 'Exportacao_NFe_Recebidas_Revizia' will be added with a trimmed name 'Exportacao_NFe_Recebidas_Revizi' for MS Excel compliance. | ||
9/10/25, 2:33:24 PM | WARN b.c.r.documentapi.service.AwsService - >> AWS: Bucket [app-document-import-prod-v2] Filename [92052.zip] | ||
9/10/25, 2:40:43 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy341.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy247.findAll(Unknown Source) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentNfe(DocumentNfeViewQueryService.java:209) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentsWithData(DocumentNfeViewQueryService.java:74) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$FastClassBySpringCGLIB$$3c6d94cf.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$EnhancerBySpringCGLIB$$56a1a2.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsNFEV2(DocumentController.java:446) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsNFEV2(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor446.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@57f468d8 on thread XNIO-1 task-16, stack trace follows | ||
9/10/25, 2:42:50 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy354.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy246.findAll(Unknown Source) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService.findDocumentNfe(DocumentNfeCanhotoViewQueryService.java:198) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService.findDocumentsWithData(DocumentNfeCanhotoViewQueryService.java:66) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService$$FastClassBySpringCGLIB$$d151a267.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService$$EnhancerBySpringCGLIB$$77cc096a.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsNFECanhoto(DocumentController.java:455) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsNFECanhoto(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor874.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@570aff71 on thread XNIO-1 task-20, stack trace follows | ||
9/10/25, 2:50:50 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy341.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy247.findAll(Unknown Source) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentNfe(DocumentNfeViewQueryService.java:209) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService.findDocumentsWithData(DocumentNfeViewQueryService.java:74) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$FastClassBySpringCGLIB$$3c6d94cf.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentNfeViewQueryService$$EnhancerBySpringCGLIB$$56a1a2.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsNFEV2(DocumentController.java:446) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsNFEV2(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor446.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@2032640d on thread XNIO-1 task-17, stack trace follows | ||
9/10/25, 2:55:00 PM | /api/feature-flag/todas GET | UsuarioAutenticadoParaServicos{id=2, email='documentos@revizia.com.br'} | WARN com.zaxxer.hikari.pool.PoolBase - Hikari - Failed to validate connection org.postgresql.jdbc.PgConnection@63aa210a (This connection has been closed.). Possibly consider using a shorter maxLifetime value. |
9/10/25, 2:58:10 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1581) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:111) at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy341.findByKeyAndDocumentTypeIn(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor385.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy247.findByKeyAndDocumentTypeIn(Unknown Source) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:56) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@584cf011 on thread XNIO-1 task-11, stack trace follows | ||
9/10/25, 2:59:16 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy354.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy246.findAll(Unknown Source) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService.findDocumentNfe(DocumentNfeCanhotoViewQueryService.java:198) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService.findDocumentsWithData(DocumentNfeCanhotoViewQueryService.java:66) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService$$FastClassBySpringCGLIB$$d151a267.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.DocumentNfeCanhotoViewQueryService$$EnhancerBySpringCGLIB$$77cc096a.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsNFECanhoto(DocumentController.java:455) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsNFECanhoto(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor874.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@28a9d90d on thread XNIO-1 task-14, stack trace follows | ||
9/10/25, 3:01:54 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1581) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:111) at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy341.findByKeyAndDocumentTypeIn(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor385.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy247.findByKeyAndDocumentTypeIn(Unknown Source) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:56) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@2032640d on thread XNIO-1 task-17, stack trace follows | ||
9/10/25, 3:02:09 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1581) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:111) at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:196) at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154) at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy341.findByKeyAndDocumentTypeIn(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor385.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy247.findByKeyAndDocumentTypeIn(Unknown Source) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl.generatePdfByKey(GeradorPdfNfeServiceImpl.java:56) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$FastClassBySpringCGLIB$$1d9c7c39.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.GeradorPdfNfeServiceImpl$$EnhancerBySpringCGLIB$$c819ce4b.generatePdfByKey(<generated>) at br.com.revizia.documentapi.controller.ReportController.generateNfeReport(ReportController.java:93) at br.com.revizia.documentapi.controller.ReportController$$FastClassBySpringCGLIB$$b115c206.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.ReportController$$EnhancerBySpringCGLIB$$958527d2.generateNfeReport(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor384.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:497) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@2032640d on thread XNIO-1 task-17, stack trace follows | ||
9/10/25, 3:02:56 PM |
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:804) at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:300) at com.sun.proxy.$Proxy129.getConnection(Unknown Source) at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:108) at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:138) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2041) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1565) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533) at org.hibernate.query.Query.getResultList(Query.java:165) at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:637) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:445) at jdk.internal.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:550) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy387.findAll(Unknown Source) at jdk.internal.reflect.GeneratedMethodAccessor318.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:205) at com.sun.proxy.$Proxy250.findAll(Unknown Source) at br.com.revizia.documentapi.service.impl.DocumentCteViewQueryService.findDocuments(DocumentCteViewQueryService.java:166) at br.com.revizia.documentapi.service.impl.DocumentCteViewQueryService.findDocumentsWithData(DocumentCteViewQueryService.java:55) at br.com.revizia.documentapi.service.impl.DocumentCteViewQueryService$$FastClassBySpringCGLIB$$d69c42f2.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.service.impl.DocumentCteViewQueryService$$EnhancerBySpringCGLIB$$c319eb.findDocumentsWithData(<generated>) at br.com.revizia.documentapi.controller.DocumentController.getDocumentsCte(DocumentController.java:464) at br.com.revizia.documentapi.controller.DocumentController$$FastClassBySpringCGLIB$$26169bad.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:76) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at br.com.revizia.documentapi.controller.DocumentController$$EnhancerBySpringCGLIB$$3505f0fc.getDocumentsCte(<generated>) at jdk.internal.reflect.GeneratedMethodAccessor487.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:584) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:113) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:65) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at java.base/java.lang.Thread.run(Unknown Source) WARN com.zaxxer.hikari.pool.ProxyLeakTask - Connection leak detection triggered for org.postgresql.jdbc.PgConnection@2032640d on thread XNIO-1 task-17, stack trace follows |
Host: | ip-10-0-15-124.ec2.internal@10.0.15.124 | |
Java memory used: | ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Nb of http sessions: | ![]() | |
Nb of active threads (current http requests): | ![]() | |
Nb of active jdbc connections: | ![]() | |
Nb of used jdbc connections (opened if no datasource): | ![]() | |
System load | ![]() | |
% System CPU | ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
OS: |
![]() |
Java: | OpenJDK Runtime Environment, 11.0.23+9 |
JVM: | OpenJDK 64-Bit Server VM, 11.0.23+9, mixed mode, sharing |
PID of process: | 7 |
Nb of opened files | ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Server: | Undertow - 2.1.4.Final |
Webapp context: | |
Start: | 9/10/25, 12:23 PM |
JVM arguments: | -Xms1024m -Xmx25600m -XX:+HeapDumpOnOutOfMemoryError -Xverify:none -XX:+AlwaysPreTouch -Djava.security.egd=file:/dev/./urandom |
Mean age of http sessions (min): | ![]() |
Memory: | Non heap memory = 337 Mb (Perm Gen, Code Cache), Buffered memory = 263 Mb, Loaded classes = 32,927, Garbage collection time = 1,826 ms, Process cpu time = 677,080 ms, Committed virtual memory = 36,727 Mb, Free physical memory = 28,649 Mb, Total physical memory = 32,768 Mb |
Free disk space: | 19,806 Mb |
Usable disk space: | 18,254 Mb |
DataBase: |
dataSource: jdbc:postgresql://bd-rvz-prod-proxy.proxy-cjipvy4ifgsj.us-east-1.rds.amazonaws.com/documents?ApplicationName=document-api&reWriteBatchedInserts=true&rewriteBatchedStatements=true&assumeMinServerVersion=9.0 PostgreSQL, 15.13 Driver JDBC: PostgreSQL JDBC Driver, 42.2.18 |
Dependencies: |
![]() |
Thread | Daemon ? | Priority | State | Executed method | Cpu time (ms) | User time (ms) | Interrupt | Kill |
---|---|---|---|---|---|---|---|---|
Common-Cleaner
java.base@11.0.23/java.lang.Object.wait(Native Method) java.base@11.0.23/java.lang.ref.ReferenceQueue.remove(Unknown Source) java.base@11.0.23/jdk.internal.ref.CleanerImpl.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) java.base@11.0.23/jdk.internal.misc.InnocuousThread.run(Unknown Source) Common-Cleaner | yes | 8 | ![]() | java.base@11.0.23/java.lang.Object.wait(Native Method) | 18 | 0 | ![]() | ![]() |
DestroyJavaVM | no | 5 | ![]() | 406 | 360 | ![]() | ![]() | |
Finalizer
java.base@11.0.23/java.lang.Object.wait(Native Method) java.base@11.0.23/java.lang.ref.ReferenceQueue.remove(Unknown Source) java.base@11.0.23/java.lang.ref.ReferenceQueue.remove(Unknown Source) java.base@11.0.23/java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source) Finalizer | yes | 8 | ![]() | java.base@11.0.23/java.lang.Object.wait(Native Method) | 77 | 70 | ![]() | ![]() |
ForkJoinPool.commonPool-worker-25
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) ForkJoinPool.commonPool-worker-25 | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 0 | 0 | ![]() | ![]() |
Hikari connection closer
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(Unknown Source) java.base@11.0.23/java.util.concurrent.LinkedBlockingQueue.poll(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) Hikari connection closer | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 0 | 0 | ![]() | ![]() |
Hikari housekeeper
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) Hikari housekeeper | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 187 | 140 | ![]() | ![]() |
HttpClient-1-SelectorManager
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) platform/java.net.http@11.0.23/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(Unknown Source) HttpClient-1-SelectorManager | yes | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 148 | 140 | ![]() | ![]() |
idle-connection-reaper
java.base@11.0.23/java.lang.Thread.sleep(Native Method) app//software.amazon.awssdk.http.apache.internal.conn.IdleConnectionReaper$ReaperTask.run(IdleConnectionReaper.java:150) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) idle-connection-reaper | yes | 5 | ![]() | java.base@11.0.23/java.lang.Thread.sleep(Native Method) | 11 | 10 | ![]() | ![]() |
java-sdk-http-connection-reaper
java.base@11.0.23/java.lang.Thread.sleep(Native Method) app//com.amazonaws.http.IdleConnectionReaper.run(IdleConnectionReaper.java:188) java-sdk-http-connection-reaper | yes | 5 | ![]() | java.base@11.0.23/java.lang.Thread.sleep(Native Method) | 13 | 10 | ![]() | ![]() |
Java2D Disposer
java.base@11.0.23/java.lang.Object.wait(Native Method) java.base@11.0.23/java.lang.ref.ReferenceQueue.remove(Unknown Source) java.base@11.0.23/java.lang.ref.ReferenceQueue.remove(Unknown Source) java.desktop@11.0.23/sun.java2d.Disposer.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) Java2D Disposer | yes | 10 | ![]() | java.base@11.0.23/java.lang.Object.wait(Native Method) | 4 | 0 | ![]() | ![]() |
javamelody
java.base@11.0.23/java.lang.Object.wait(Native Method) java.base@11.0.23/java.util.TimerThread.mainLoop(Unknown Source) java.base@11.0.23/java.util.TimerThread.run(Unknown Source) javamelody | yes | 5 | ![]() | java.base@11.0.23/java.lang.Object.wait(Native Method) | 7,685 | 7,020 | ![]() | ![]() |
parallel-1
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) parallel-1 | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 0 | 0 | ![]() | ![]() |
PostgreSQL-JDBC-SharedTimer-1
java.base@11.0.23/java.lang.Object.wait(Native Method) java.base@11.0.23/java.util.TimerThread.mainLoop(Unknown Source) java.base@11.0.23/java.util.TimerThread.run(Unknown Source) PostgreSQL-JDBC-SharedTimer-1 | yes | 5 | ![]() | java.base@11.0.23/java.lang.Object.wait(Native Method) | 102 | 80 | ![]() | ![]() |
reactor-http-epoll-11
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-11 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,368 | 1,120 | ![]() | ![]() |
reactor-http-epoll-13
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-13 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,446 | 1,230 | ![]() | ![]() |
reactor-http-epoll-15
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-15 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,636 | 1,360 | ![]() | ![]() |
reactor-http-epoll-17
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-17 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,447 | 1,220 | ![]() | ![]() |
reactor-http-epoll-19
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-19 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 826 | 750 | ![]() | ![]() |
reactor-http-epoll-2
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-2 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 917 | 820 | ![]() | ![]() |
reactor-http-epoll-21
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-21 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 710 | 590 | ![]() | ![]() |
reactor-http-epoll-23
app//io.netty.channel.epoll.Native.epollWait0(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:132) app//io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:281) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:351) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-23 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait0(Native Method) | 409 | 340 | ![]() | ![]() |
reactor-http-epoll-25
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-25 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,164 | 970 | ![]() | ![]() |
reactor-http-epoll-27
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-27 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,002 | 850 | ![]() | ![]() |
reactor-http-epoll-29
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-29 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,131 | 980 | ![]() | ![]() |
reactor-http-epoll-31
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-31 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 284 | 250 | ![]() | ![]() |
reactor-http-epoll-33
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-33 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 991 | 860 | ![]() | ![]() |
reactor-http-epoll-5
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-5 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,649 | 1,390 | ![]() | ![]() |
reactor-http-epoll-7
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-7 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,573 | 1,370 | ![]() | ![]() |
reactor-http-epoll-9
app//io.netty.channel.epoll.Native.epollWait(Native Method) app//io.netty.channel.epoll.Native.epollWait(Native.java:148) app//io.netty.channel.epoll.Native.epollWait(Native.java:141) app//io.netty.channel.epoll.EpollEventLoop.epollWaitNoTimerChange(EpollEventLoop.java:290) app//io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:347) app//io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) java.base@11.0.23/java.lang.Thread.run(Unknown Source) reactor-http-epoll-9 | yes | 5 | ![]() | app//io.netty.channel.epoll.Native.epollWait(Native Method) | 1,549 | 1,370 | ![]() | ![]() |
Reference Handler
java.base@11.0.23/java.lang.ref.Reference.waitForReferencePendingList(Native Method) java.base@11.0.23/java.lang.ref.Reference.processPendingReferences(Unknown Source) java.base@11.0.23/java.lang.ref.Reference$ReferenceHandler.run(Unknown Source) Reference Handler | yes | 10 | ![]() | java.base@11.0.23/java.lang.ref.Reference.waitForReferencePendingList(Native Method) | 53 | 50 | ![]() | ![]() |
rvz-down-doc-async-1
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.base@11.0.23/java.util.concurrent.LinkedBlockingQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) rvz-down-doc-async-1 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 676 | 660 | ![]() | ![]() |
rvz-down-doc-async-2
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.base@11.0.23/java.util.concurrent.LinkedBlockingQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) rvz-down-doc-async-2 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 128 | 120 | ![]() | ![]() |
rvz-down-doc-async-3
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.base@11.0.23/java.util.concurrent.LinkedBlockingQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) rvz-down-doc-async-3 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 394 | 370 | ![]() | ![]() |
sdk-ScheduledExecutor-0-0
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) sdk-ScheduledExecutor-0-0 | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 0 | 0 | ![]() | ![]() |
sdk-ScheduledExecutor-0-1
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) sdk-ScheduledExecutor-0-1 | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 0 | 0 | ![]() | ![]() |
sdk-ScheduledExecutor-0-2
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) sdk-ScheduledExecutor-0-2 | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 0 | 0 | ![]() | ![]() |
sdk-ScheduledExecutor-0-3
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) sdk-ScheduledExecutor-0-3 | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 0 | 0 | ![]() | ![]() |
sdk-ScheduledExecutor-0-4
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) sdk-ScheduledExecutor-0-4 | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 0 | 0 | ![]() | ![]() |
Signal Dispatcher | yes | 9 | ![]() | 0 | 0 | ![]() | ![]() | |
Thread-54
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source) java.base@11.0.23/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.base@11.0.23/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) java.base@11.0.23/java.lang.Thread.run(Unknown Source) Thread-54 | yes | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 1,656 | 1,380 | ![]() | ![]() |
XNIO-1 Accept
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:532) XNIO-1 Accept | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 169 | 110 | ![]() | ![]() |
XNIO-1 I/O-1
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-1 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 49 | 30 | ![]() | ![]() |
XNIO-1 I/O-10
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-10 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 381 | 280 | ![]() | ![]() |
XNIO-1 I/O-11
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-11 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 52 | 30 | ![]() | ![]() |
XNIO-1 I/O-12
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-12 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 575 | 440 | ![]() | ![]() |
XNIO-1 I/O-13
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-13 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 20 | 0 | ![]() | ![]() |
XNIO-1 I/O-14
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-14 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 1,027 | 710 | ![]() | ![]() |
XNIO-1 I/O-15
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-15 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 79 | 40 | ![]() | ![]() |
XNIO-1 I/O-16
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:532) XNIO-1 I/O-16 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 91 | 40 | ![]() | ![]() |
XNIO-1 I/O-2
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:532) XNIO-1 I/O-2 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 185 | 130 | ![]() | ![]() |
XNIO-1 I/O-3
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-3 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 508 | 370 | ![]() | ![]() |
XNIO-1 I/O-4
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-4 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 1,169 | 800 | ![]() | ![]() |
XNIO-1 I/O-5
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-5 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 351 | 270 | ![]() | ![]() |
XNIO-1 I/O-6
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-6 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 368 | 290 | ![]() | ![]() |
XNIO-1 I/O-7
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:532) XNIO-1 I/O-7 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 254 | 210 | ![]() | ![]() |
XNIO-1 I/O-8
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-8 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 64 | 40 | ![]() | ![]() |
XNIO-1 I/O-9
java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) java.base@11.0.23/sun.nio.ch.EPollSelectorImpl.doSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source) java.base@11.0.23/sun.nio.ch.SelectorImpl.select(Unknown Source) app//org.xnio.nio.WorkerThread.run(WorkerThread.java:551) XNIO-1 I/O-9 | no | 5 | ![]() | java.base@11.0.23/sun.nio.ch.EPoll.wait(Native Method) | 562 | 460 | ![]() | ![]() |
XNIO-1 task-1
java.base@11.0.23/java.io.ObjectOutputStream$BlockDataOutputStream.getUTFLength(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeString(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeObject0(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeObject(Unknown Source) java.base@11.0.23/java.util.concurrent.ConcurrentHashMap.writeObject(Unknown Source) java.base@11.0.23/jdk.internal.reflect.GeneratedMethodAccessor247.invoke(Unknown Source) java.base@11.0.23/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.base@11.0.23/java.lang.reflect.Method.invoke(Unknown Source) java.base@11.0.23/java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeSerialData(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeObject0(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeSerialData(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeObject0(Unknown Source) java.base@11.0.23/java.io.ObjectOutputStream.writeObject(Unknown Source) app//net.bull.javamelody.internal.model.CounterStorage.writeToFile(CounterStorage.java:125) app//net.bull.javamelody.internal.model.CounterStorage.writeToFile(CounterStorage.java:117) app//net.bull.javamelody.internal.model.Counter.writeToFile(Counter.java:944) app//net.bull.javamelody.internal.model.Collector.collectCounterData(Collector.java:742) app//net.bull.javamelody.internal.model.Collector.collect(Collector.java:363) app//net.bull.javamelody.internal.model.Collector.collectWithoutErrors(Collector.java:329) app//net.bull.javamelody.internal.model.Collector.collectLocalContextWithoutErrors(Collector.java:318) app//net.bull.javamelody.internal.web.HtmlController.doHtml(HtmlController.java:98) app//net.bull.javamelody.internal.web.MonitoringController.doCompressedHtml(MonitoringController.java:280) app//net.bull.javamelody.internal.web.MonitoringController.doReportCore(MonitoringController.java:230) app//net.bull.javamelody.internal.web.MonitoringController.doReport(MonitoringController.java:209) app//net.bull.javamelody.internal.web.MonitoringController.doActionIfNeededAndReport(MonitoringController.java:163) app//net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:408) app//net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) app//org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) app//org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) app//org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) app//org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) app//org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) app//org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) app//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) app//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) app//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) app//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) app//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) app//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) app//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) app//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) app//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) app//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) app//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) app//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) app//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) app//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) app//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) app//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) app//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) app//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) app//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) app//io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) app//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) app//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) app//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-1 | no | 5 | ![]() | java.base@11.0.23/java.io.ObjectOutputStream$BlockDataOutputStream.getUTFLength(Unknown Source) | 29,440 | 27,380 | ![]() | ![]() |
XNIO-1 task-10
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-10 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 6,526 | 6,060 | ![]() | ![]() |
XNIO-1 task-11
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-11 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 28,259 | 27,510 | ![]() | ![]() |
XNIO-1 task-12
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-12 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 7,101 | 6,600 | ![]() | ![]() |
XNIO-1 task-13
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-13 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 3,808 | 3,550 | ![]() | ![]() |
XNIO-1 task-14
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-14 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 21,613 | 20,480 | ![]() | ![]() |
XNIO-1 task-15
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-15 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 8,431 | 7,920 | ![]() | ![]() |
XNIO-1 task-16
app//net.bull.javamelody.internal.model.Collector.collect(Collector.java:343) app//net.bull.javamelody.internal.model.Collector.collectWithoutErrors(Collector.java:329) app//net.bull.javamelody.internal.model.Collector.collectLocalContextWithoutErrors(Collector.java:318) app//net.bull.javamelody.internal.web.HtmlController.doHtml(HtmlController.java:98) app//net.bull.javamelody.internal.web.MonitoringController.doCompressedHtml(MonitoringController.java:280) app//net.bull.javamelody.internal.web.MonitoringController.doReportCore(MonitoringController.java:230) app//net.bull.javamelody.internal.web.MonitoringController.doReport(MonitoringController.java:209) app//net.bull.javamelody.internal.web.MonitoringController.doActionIfNeededAndReport(MonitoringController.java:163) app//net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:408) app//net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) app//org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) app//org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) app//org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) app//org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) app//org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) app//org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) app//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) app//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) app//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) app//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) app//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) app//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) app//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) app//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) app//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) app//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) app//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) app//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) app//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) app//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) app//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) app//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) app//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) app//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) app//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) app//io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) app//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) app//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) app//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-16 | no | 5 | ![]() | app//net.bull.javamelody.internal.model.Collector.collect(Collector.java:343) | 21,680 | 20,490 | ![]() | ![]() |
XNIO-1 task-17
java.base@11.0.23/java.lang.Thread.dumpThreads(Native Method) java.base@11.0.23/java.lang.Thread.getAllStackTraces(Unknown Source) app//net.bull.javamelody.internal.model.JavaInformations.buildThreadInformationsList(JavaInformations.java:327) app//net.bull.javamelody.internal.model.JavaInformations.<init>(JavaInformations.java:202) app//net.bull.javamelody.internal.web.MonitoringController.doActionIfNeededAndReport(MonitoringController.java:158) app//net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:408) app//net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) app//org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) app//org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) br.com.revizia.documentapi.config.security.jwt.JwtTokenFilter.doFilterInternal(JwtTokenFilter.java:86) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) app//org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) app//org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) app//org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) app//org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) app//org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) app//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) app//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) app//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) app//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) app//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) app//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) app//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) app//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) app//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) app//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) app//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) app//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) app//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) app//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) app//io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119) app//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) app//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) app//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) app//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) app//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) app//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) app//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) app//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) app//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) app//io.undertow.server.Connectors.executeRootHandler(Connectors.java:370) app//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:836) app//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) app//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-17 | no | 5 | ![]() | java.base@11.0.23/java.lang.Thread.dumpThreads(Native Method) | 61,252 | 59,510 | ![]() | ![]() |
XNIO-1 task-18
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-18 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 5,367 | 5,000 | ![]() | ![]() |
XNIO-1 task-19
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-19 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 9,045 | 8,400 | ![]() | ![]() |
XNIO-1 task-2
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-2 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 2,489 | 2,280 | ![]() | ![]() |
XNIO-1 task-20
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-20 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 15,007 | 14,180 | ![]() | ![]() |
XNIO-1 task-21
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-21 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 7,025 | 6,630 | ![]() | ![]() |
XNIO-1 task-3
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-3 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 13,635 | 12,850 | ![]() | ![]() |
XNIO-1 task-4
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-4 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 3,676 | 3,360 | ![]() | ![]() |
XNIO-1 task-5
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-5 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 8,396 | 7,830 | ![]() | ![]() |
XNIO-1 task-6
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-6 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 11,170 | 10,560 | ![]() | ![]() |
XNIO-1 task-7
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-7 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 13,450 | 12,550 | ![]() | ![]() |
XNIO-1 task-8
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-8 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 6,558 | 6,140 | ![]() | ![]() |
XNIO-1 task-9
java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) java.base@11.0.23/java.util.concurrent.locks.LockSupport.park(Unknown Source) app//org.jboss.threads.EnhancedQueueExecutor$PoolThreadNode.park(EnhancedQueueExecutor.java:2194) app//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1481) java.base@11.0.23/java.lang.Thread.run(Unknown Source) XNIO-1 task-9 | no | 5 | ![]() | java.base@11.0.23/jdk.internal.misc.Unsafe.park(Native Method) | 2,189 | 2,080 | ![]() | ![]() |