Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String sql = "select\n" +
- " s.id_sessao,\n" +
- " s.dt_sessao data_sessao,\n" +
- " s.nr_horario_inicio hora_sessao,\n" +
- " ojc.id_orgao_julgador_colegiado orgao_julgador_colegiado_id,\n" +
- " ojc.ds_orgao_julgador_colegiado orgao_julgador_colegiado,\n" +
- " oj.ds_orgao_julgador relator,\n" +
- " spp.nr_ordem ordem_inclusao,\n" +
- " p.nr_processo numero,\n" +
- " cj.ds_classe_judicial || ' (' || cj.cd_classe_judicial || ')' classe,\n" +
- " 'Ainda não é possível extrair comarca do PJe' comarca_origem,\n" +
- " 'Ainda não é possível extrair vara do PJe' vara_origem,\n" +
- " tpa.tipos adjetivopoloativo,\n" +
- " pat.partes poloativo,\n" +
- " rpa.nomes representantepoloativo,\n" +
- " tpp.tipos adjetivopolopassivo,\n" +
- " ppa.partes polopassivo,\n" +
- " rpp.nomes representantepolopassivo\n" +
- "from\n" +
- " client.tb_sessao s\n" +
- "join client.tb_orgao_julgador_colgiado ojc on\n" +
- " ojc.id_orgao_julgador_colegiado = s.id_orgao_julgador_colegiado\n" +
- "join client.tb_sessao_pauta_proc_trf spp on\n" +
- " spp.id_sessao = s.id_sessao\n" +
- "join core.tb_processo p on\n" +
- " p.id_processo = spp.id_processo_trf\n" +
- "join client.tb_processo_trf pt on\n" +
- " pt.id_processo_trf = p.id_processo\n" +
- "join client.tb_orgao_julgador oj on\n" +
- " oj.id_orgao_julgador = pt.id_orgao_julgador\n" +
- "join client.tb_classe_judicial cj on\n" +
- " cj.id_classe_judicial = pt.id_classe_judicial\n" +
- "join (\n" +
- " select\n" +
- " prt.id_processo_trf,\n" +
- " array_to_string(array_agg( case when not prt.in_segredo_justica then ul.ds_nome else ( select array_to_string( array_agg (left(nome, 1)), '.' ) from ( select unnest (string_to_array(ul.ds_nome, ' ')) nome ) a where nome not in ('DE', 'DA', 'DO', 'E', 'DAS', 'DOS') ) end ), ',') partes\n" +
- " from\n" +
- " client.tb_processo_parte pp\n" +
- " join acl.tb_usuario_login ul on\n" +
- " pp.id_pessoa = ul.id_usuario\n" +
- " join client.tb_processo_trf prt on\n" +
- " pp.id_processo_trf = prt.id_processo_trf\n" +
- " where\n" +
- " in_participacao = 'A'\n" +
- " and in_parte_principal\n" +
- " group by\n" +
- " prt.id_processo_trf ) pat on\n" +
- " pat.id_processo_trf = pt.id_processo_trf\n" +
- "join (\n" +
- " select\n" +
- " pp.id_processo_trf,\n" +
- " array_to_string(array_agg(cast(tp.ds_tipo_parte as text)), ',') tipos\n" +
- " from\n" +
- " client.tb_processo_parte pp\n" +
- " join client.tb_tipo_parte tp on\n" +
- " pp.id_tipo_parte = tp.id_tipo_parte\n" +
- " where\n" +
- " in_participacao = 'A'\n" +
- " and in_parte_principal\n" +
- " group by\n" +
- " pp.id_processo_trf) tpa on\n" +
- " pt.id_processo_trf = tpa.id_processo_trf\n" +
- "left join (\n" +
- " select\n" +
- " prt.id_processo_trf,\n" +
- " array_to_string(array_agg( case when not prt.in_segredo_justica then ul.ds_nome else ( select array_to_string( array_agg (left(nome, 1)), '.' ) from ( select unnest (string_to_array(ul.ds_nome, ' ')) nome ) a where nome not in ('DE', 'DA', 'DO', 'E', 'DAS', 'DOS') ) end ), ',') partes\n" +
- " from\n" +
- " client.tb_processo_parte pp\n" +
- " join acl.tb_usuario_login ul on\n" +
- " pp.id_pessoa = ul.id_usuario\n" +
- " join client.tb_processo_trf prt on\n" +
- " pp.id_processo_trf = prt.id_processo_trf\n" +
- " where\n" +
- " in_participacao = 'P'\n" +
- " and in_parte_principal\n" +
- " group by\n" +
- " prt.id_processo_trf ) ppa on\n" +
- " ppa.id_processo_trf = pt.id_processo_trf\n" +
- "left join (\n" +
- " select\n" +
- " pp.id_processo_trf,\n" +
- " array_to_string(array_agg(cast(tp.ds_tipo_parte as text)), ',') tipos\n" +
- " from\n" +
- " client.tb_processo_parte pp\n" +
- " join client.tb_tipo_parte tp on\n" +
- " pp.id_tipo_parte = tp.id_tipo_parte\n" +
- " where\n" +
- " in_participacao = 'P'\n" +
- " and in_parte_principal\n" +
- " group by\n" +
- " pp.id_processo_trf) tpp on\n" +
- " pt.id_processo_trf = tpp.id_processo_trf\n" +
- "left join (\n" +
- " select\n" +
- " id_processo_trf,\n" +
- " array_to_string(array_agg(distinct ds_nome), ',') nomes\n" +
- " from\n" +
- " (\n" +
- " select\n" +
- " pp.id_processo_trf,\n" +
- " ul.ds_nome\n" +
- " from\n" +
- " client.tb_processo_parte pp\n" +
- " join acl.tb_usuario_login ul on\n" +
- " pp.id_pessoa = ul.id_usuario\n" +
- " where\n" +
- " in_participacao = 'A'\n" +
- " and not in_parte_principal\n" +
- " union all\n" +
- " select\n" +
- " pp.id_processo_trf,\n" +
- " pr.ds_nome\n" +
- " from\n" +
- " client.tb_processo_parte pp\n" +
- " join acl.tb_usuario_login ul on\n" +
- " pp.id_pessoa = ul.id_usuario\n" +
- " join client.tb_procuradoria pr on\n" +
- " pp.id_procuradoria = pr.id_procuradoria\n" +
- " where\n" +
- " in_participacao = 'A'\n" +
- " and in_parte_principal) prc\n" +
- " group by\n" +
- " id_processo_trf) rpa on\n" +
- " pt.id_processo_trf = rpa.id_processo_trf\n" +
- "left join (\n" +
- " select\n" +
- " id_processo_trf,\n" +
- " array_to_string(array_agg(distinct ds_nome), ',') nomes\n" +
- " from\n" +
- " (\n" +
- " select\n" +
- " pp.id_processo_trf,\n" +
- " ul.ds_nome\n" +
- " from\n" +
- " client.tb_processo_parte pp\n" +
- " join acl.tb_usuario_login ul on\n" +
- " pp.id_pessoa = ul.id_usuario\n" +
- " where\n" +
- " in_participacao = 'P'\n" +
- " and not in_parte_principal\n" +
- " union all\n" +
- " select\n" +
- " pp.id_processo_trf,\n" +
- " pr.ds_nome\n" +
- " from\n" +
- " client.tb_processo_parte pp\n" +
- " join acl.tb_usuario_login ul on\n" +
- " pp.id_pessoa = ul.id_usuario\n" +
- " join client.tb_procuradoria pr on\n" +
- " pp.id_procuradoria = pr.id_procuradoria\n" +
- " where\n" +
- " in_participacao = 'P'\n" +
- " and in_parte_principal) prc\n" +
- " group by\n" +
- " id_processo_trf) rpp on\n" +
- " pt.id_processo_trf = rpp.id_processo_trf\n" +
- "where\n" +
- " s.dt_sessao >= :dataSessao and\n" +
- " s.in_continua = true\n" +
- " and spp.dt_exclusao_processo is null\n" +
- " and s.dt_fechamento_sessao is not null\n" +
- " \n" +
- "order by\n" +
- " s.dt_sessao desc,\n" +
- " p.nr_processo";
- Query query = em.createNativeQuery(sql);
- List<SessaoProcesso> sessaoProcessos = query.getResultList();
- for (SessaoProcesso sessaoProcesso : sessaoProcessos) {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement