Commit 3963c34029cec16ebdd987bc5cdcf0538482772a
1 parent
427061b9
Exists in
master
and in
1 other branch
Correção em query que estava ignorando um filtro e não estava agrupando os resultados.
Showing
2 changed files
with
24 additions
and
4 deletions
Show diff stats
src/main/java/br/gov/ans/integracao/sei/dao/ProcessoDAO.java
@@ -44,11 +44,19 @@ public class ProcessoDAO { | @@ -44,11 +44,19 @@ public class ProcessoDAO { | ||
44 | } | 44 | } |
45 | 45 | ||
46 | if(StringUtils.isNoneBlank(tipoProcesso)){ | 46 | if(StringUtils.isNoneBlank(tipoProcesso)){ |
47 | - builder.append("AND proc.id_tipo_procedimento = :tipoProcesso "); | 47 | + builder.append("AND proc.id_tipo_procedimento = :tipoProcesso "); |
48 | + parametros.put("tipoProcesso", tipoProcesso); | ||
48 | } | 49 | } |
49 | - | 50 | + |
50 | builder.append("AND tp.id_tipo_procedimento = proc.id_tipo_procedimento "); | 51 | builder.append("AND tp.id_tipo_procedimento = proc.id_tipo_procedimento "); |
51 | 52 | ||
53 | + if(StringUtils.isNoneBlank(unidade)){ | ||
54 | + builder.append("AND p.id_unidade = :unidade "); | ||
55 | + parametros.put("unidade", unidade); | ||
56 | + } | ||
57 | + | ||
58 | + builder.append("group by pr.protocolo_formatado_pesquisa "); | ||
59 | + | ||
52 | if(crescente){ | 60 | if(crescente){ |
53 | builder.append("order by pr.dta_geracao asc"); | 61 | builder.append("order by pr.dta_geracao asc"); |
54 | }else{ | 62 | }else{ |
@@ -93,11 +101,19 @@ public class ProcessoDAO { | @@ -93,11 +101,19 @@ public class ProcessoDAO { | ||
93 | } | 101 | } |
94 | 102 | ||
95 | if(StringUtils.isNoneBlank(tipoProcesso)){ | 103 | if(StringUtils.isNoneBlank(tipoProcesso)){ |
96 | - builder.append("AND proc.id_tipo_procedimento = :tipoProcesso "); | 104 | + builder.append("AND proc.id_tipo_procedimento = :tipoProcesso "); |
105 | + parametros.put("tipoProcesso", tipoProcesso); | ||
97 | } | 106 | } |
98 | 107 | ||
99 | builder.append("AND tp.id_tipo_procedimento = proc.id_tipo_procedimento "); | 108 | builder.append("AND tp.id_tipo_procedimento = proc.id_tipo_procedimento "); |
100 | 109 | ||
110 | + if(StringUtils.isNoneBlank(unidade)){ | ||
111 | + builder.append("AND p.id_unidade = :unidade "); | ||
112 | + parametros.put("unidade", unidade); | ||
113 | + } | ||
114 | + | ||
115 | + builder.append("group by pr.protocolo_formatado_pesquisa "); | ||
116 | + | ||
101 | Query query = em.createNativeQuery(builder.toString()); | 117 | Query query = em.createNativeQuery(builder.toString()); |
102 | 118 | ||
103 | setQueryParameters(query, parametros); | 119 | setQueryParameters(query, parametros); |
src/main/java/br/gov/ans/integracao/sei/rest/ProcessoResource.java
@@ -620,7 +620,11 @@ public class ProcessoResource { | @@ -620,7 +620,11 @@ public class ProcessoResource { | ||
620 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | 620 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
621 | @Wrapped(element = "processos") | 621 | @Wrapped(element = "processos") |
622 | public Response consultarProcessos(@QueryParam("interessado") String interessado, @QueryParam("unidade") String unidade, @QueryParam("tipo") String tipoProcesso, | 622 | public Response consultarProcessos(@QueryParam("interessado") String interessado, @QueryParam("unidade") String unidade, @QueryParam("tipo") String tipoProcesso, |
623 | - @QueryParam("crescente") boolean crescente, @QueryParam("pagina") String pagina, @QueryParam("qtdRegistros") String qtdRegistros) throws BusinessException{ | 623 | + @QueryParam("crescente") boolean crescente, @QueryParam("pagina") String pagina, @QueryParam("qtdRegistros") String qtdRegistros) throws Exception{ |
624 | + | ||
625 | + if(StringUtils.isNotBlank(unidade)){ | ||
626 | + unidade = unidadeResource.consultarCodigo(unidade); | ||
627 | + } | ||
624 | 628 | ||
625 | List<ProcessoResumido> processos = processoDAO.getProcessos(interessado, unidade, tipoProcesso, | 629 | List<ProcessoResumido> processos = processoDAO.getProcessos(interessado, unidade, tipoProcesso, |
626 | pagina == null? null:parseInt(pagina), qtdRegistros == null? null : parseInt(qtdRegistros), crescente); | 630 | pagina == null? null:parseInt(pagina), qtdRegistros == null? null : parseInt(qtdRegistros), crescente); |