Commit a1e3c1bb0900ad1716c1c3819273f1b916cf7cc8
1 parent
fb4a12ef
Exists in
master
and in
1 other branch
Adiciona consulta a unidades do processo
Inclusão de serviço que consulte as unidades onde o processo está aberto.
Showing
6 changed files
with
65 additions
and
6 deletions
Show diff stats
pom.xml
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <modelVersion>4.0.0</modelVersion> |
5 | 5 | <groupId>br.gov.ans</groupId> |
6 | 6 | <artifactId>sei-broker</artifactId> |
7 | - <version>2.5.1</version> | |
7 | + <version>2.6</version> | |
8 | 8 | <packaging>war</packaging> |
9 | 9 | <name>sei-broker</name> |
10 | 10 | <description>Camada de integração REST para comunicação com o SEI</description> | ... | ... |
src/main/java/br/gov/ans/integracao/sei/client/Unidade.java
... | ... | @@ -7,15 +7,19 @@ |
7 | 7 | |
8 | 8 | package br.gov.ans.integracao.sei.client; |
9 | 9 | |
10 | +import javax.persistence.Entity; | |
11 | +import javax.persistence.Id; | |
10 | 12 | import javax.xml.bind.annotation.XmlRootElement; |
11 | 13 | |
12 | 14 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; |
13 | 15 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
14 | 16 | |
17 | +@Entity | |
15 | 18 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) |
16 | 19 | @JsonIgnoreProperties(ignoreUnknown = true) |
17 | 20 | @XmlRootElement |
18 | 21 | public class Unidade implements java.io.Serializable { |
22 | + @Id | |
19 | 23 | private java.lang.String idUnidade; |
20 | 24 | |
21 | 25 | private java.lang.String sigla; |
... | ... | @@ -166,7 +170,8 @@ public class Unidade implements java.io.Serializable { |
166 | 170 | this.sinOuvidoria = sinOuvidoria; |
167 | 171 | } |
168 | 172 | |
169 | - private java.lang.Object __equalsCalc = null; | |
173 | + private transient java.lang.Object __equalsCalc = null; | |
174 | + | |
170 | 175 | public synchronized boolean equals(java.lang.Object obj) { |
171 | 176 | if (!(obj instanceof Unidade)) return false; |
172 | 177 | Unidade other = (Unidade) obj; |
... | ... | @@ -200,7 +205,8 @@ public class Unidade implements java.io.Serializable { |
200 | 205 | return _equals; |
201 | 206 | } |
202 | 207 | |
203 | - private boolean __hashCodeCalc = false; | |
208 | + private transient boolean __hashCodeCalc = false; | |
209 | + | |
204 | 210 | public synchronized int hashCode() { |
205 | 211 | if (__hashCodeCalc) { |
206 | 212 | return 0; | ... | ... |
src/main/java/br/gov/ans/integracao/sei/dao/UnidadeDAO.java
0 → 100644
... | ... | @@ -0,0 +1,33 @@ |
1 | +package br.gov.ans.integracao.sei.dao; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +import javax.persistence.EntityManager; | |
6 | +import javax.persistence.PersistenceContext; | |
7 | +import javax.persistence.PersistenceContextType; | |
8 | +import javax.persistence.Query; | |
9 | + | |
10 | +import br.gov.ans.integracao.sei.client.Unidade; | |
11 | + | |
12 | +public class UnidadeDAO { | |
13 | + @PersistenceContext(unitName = "sei_pu", type = PersistenceContextType.EXTENDED) | |
14 | + private EntityManager em; | |
15 | + | |
16 | + public List<Unidade> listarUnidadesProcesso(String idProcedimento){ | |
17 | + StringBuilder sql = new StringBuilder("SELECT u.id_unidade idUnidade, u.sigla, u.descricao, u.sin_protocolo sinProtocolo, "); | |
18 | + sql.append("u.sin_arquivamento sinArquivamento, u.sin_ouvidoria sinOuvidoria "); | |
19 | + sql.append("FROM protocolo p "); | |
20 | + sql.append("JOIN atividade a ON p.id_protocolo = a.id_protocolo "); | |
21 | + sql.append("JOIN unidade u ON a.id_unidade = u.id_unidade "); | |
22 | + sql.append("JOIN tarefa t ON a.id_tarefa = t.id_tarefa "); | |
23 | + sql.append("WHERE p.id_protocolo = :protocolo "); | |
24 | + sql.append("and t.id_tarefa in (32, 29) "); | |
25 | + sql.append("group by u.id_unidade order by u.idx_unidade; "); | |
26 | + | |
27 | + Query query = em.createNativeQuery(sql.toString(), Unidade.class); | |
28 | + | |
29 | + query.setParameter("protocolo", idProcedimento); | |
30 | + | |
31 | + return query.getResultList(); | |
32 | + } | |
33 | +} | ... | ... |
src/main/java/br/gov/ans/integracao/sei/rest/ProcessoResource.java
... | ... | @@ -46,12 +46,13 @@ import br.gov.ans.integracao.sei.client.RetornoConsultaProcedimento; |
46 | 46 | import br.gov.ans.integracao.sei.client.RetornoGeracaoProcedimento; |
47 | 47 | import br.gov.ans.integracao.sei.client.SeiPortTypeProxy; |
48 | 48 | import br.gov.ans.integracao.sei.client.TipoProcedimento; |
49 | +import br.gov.ans.integracao.sei.client.Unidade; | |
49 | 50 | import br.gov.ans.integracao.sei.dao.DocumentoDAO; |
50 | 51 | import br.gov.ans.integracao.sei.dao.ProcessoDAO; |
51 | 52 | import br.gov.ans.integracao.sei.dao.SiparDAO; |
53 | +import br.gov.ans.integracao.sei.dao.UnidadeDAO; | |
52 | 54 | import br.gov.ans.integracao.sei.modelo.DocumentoResumido; |
53 | 55 | import br.gov.ans.integracao.sei.modelo.EnvioDeProcesso; |
54 | -import br.gov.ans.integracao.sei.modelo.InclusaoDocumento; | |
55 | 56 | import br.gov.ans.integracao.sei.modelo.Motivo; |
56 | 57 | import br.gov.ans.integracao.sei.modelo.NovoAndamento; |
57 | 58 | import br.gov.ans.integracao.sei.modelo.NovoProcesso; |
... | ... | @@ -78,6 +79,9 @@ public class ProcessoResource { |
78 | 79 | |
79 | 80 | @Inject |
80 | 81 | private DocumentoDAO documentoDAO; |
82 | + | |
83 | + @Inject | |
84 | + private UnidadeDAO unidadeDAO; | |
81 | 85 | |
82 | 86 | @Inject |
83 | 87 | private SeiPortTypeProxy seiNativeService; |
... | ... | @@ -1295,6 +1299,21 @@ public class ProcessoResource { |
1295 | 1299 | } |
1296 | 1300 | } |
1297 | 1301 | |
1302 | + @GET | |
1303 | + @Path("/processos/{processo:\\d+}/unidades") | |
1304 | + @Produces(MediaType.APPLICATION_JSON) | |
1305 | + public Response consultarUnidadesProcesso(@PathParam("processo") String processo) throws Exception{ | |
1306 | + String idProcedimento = consultarIdProcedimento(processo); | |
1307 | + | |
1308 | + List<Unidade> unidades = unidadeDAO.listarUnidadesProcesso(idProcedimento); | |
1309 | + | |
1310 | + if(unidades.isEmpty()){ | |
1311 | + throw new ResourceNotFoundException(messages.getMessage("erro.nao.unidades.processo.aberto")); | |
1312 | + } | |
1313 | + | |
1314 | + return Response.ok(unidades).build(); | |
1315 | + } | |
1316 | + | |
1298 | 1317 | public URI getResourcePath(String resourceId){ |
1299 | 1318 | UriBuilder builder = uriInfo.getAbsolutePathBuilder(); |
1300 | 1319 | ... | ... |
src/main/java/br/gov/ans/utils/PDFUtil.java
... | ... | @@ -16,10 +16,10 @@ public class PDFUtil { |
16 | 16 | tidy.setXHTML(true); |
17 | 17 | |
18 | 18 | Document document = tidy.parseDOM(new ByteArrayInputStream(bytes), null); |
19 | - | |
19 | + | |
20 | 20 | ITextRenderer renderer = new ITextRenderer(); |
21 | 21 | renderer.setDocument(document, null); |
22 | - renderer.layout(); | |
22 | + renderer.layout(); | |
23 | 23 | |
24 | 24 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
25 | 25 | renderer.createPDF(outputStream); | ... | ... |
src/main/resources/messages.properties
... | ... | @@ -30,6 +30,7 @@ erro.campos.obrigatorios.sobrestamento.processo = É necessário informar o número |
30 | 30 | erro.marcar.processo = Ocorreu um erro ao adicionar o marcador ao processo. |
31 | 31 | erro.motivo.cancelamento.obrigatorio = É obrigatório informar o motivo do cancelamento. |
32 | 32 | erro.motivo.nao.infomado = Motivo não informado. |
33 | +erro.nao.unidades.processo.aberto = Não há unidades onde o processo esteja aberto. | |
33 | 34 | erro.nenhum.contato.encontrado = Nenhum contato encontrado. |
34 | 35 | erro.nenhum.documento.encontrado.interessado = Nenhum documento foi encontrado para o interessado {0}. |
35 | 36 | erro.nenhum.processo.encontrado.filtros = Nenhum processo encontrado para os filtros informados. | ... | ... |