Commit 260e01bbe34288139e8c8599123aa8dfbae8abaf
1 parent
ad0d6f0e
Exists in
master
[Redmine Atendimento #4126] Consulta e geração de termos do contrato
Showing
25 changed files
with
882 additions
and
486 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/dao/ContratoEventoDao.java
1 | 1 | package br.com.centralit.api.dao; |
2 | 2 | |
3 | 3 | import java.util.Collection; |
4 | +import java.util.Date; | |
5 | +import java.util.List; | |
4 | 6 | |
5 | 7 | import br.com.centralit.api.model.ContratoEvento; |
6 | 8 | import br.com.centralit.framework.dao.arquitetura.CitGenericDAO; |
... | ... | @@ -44,4 +46,8 @@ public interface ContratoEventoDao extends CitGenericDAO { |
44 | 46 | Collection<ContratoEvento> findAllByContrato(Long contratoId); |
45 | 47 | |
46 | 48 | Collection<ContratoEvento> findAllByContratoTipoEvento(Long contratoId, Long tipoEvento); |
49 | + | |
50 | + Collection<ContratoEvento> findAllByContratoIntervalDataEmissao(Long contratoId, Date dataInicial, Date dateFinal); | |
51 | + | |
52 | + Collection<ContratoEvento> findAllByContratoTipoTermoDataEmissao(List<Long> codigosTermo, Date dataInicial, Date dateFinal); | |
47 | 53 | } |
48 | 54 | \ No newline at end of file | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/dao/impl/ContratoEventoDaoHibernate.java
1 | 1 | package br.com.centralit.api.dao.impl; |
2 | 2 | |
3 | +import java.text.SimpleDateFormat; | |
3 | 4 | import java.util.Collection; |
5 | +import java.util.Date; | |
6 | +import java.util.List; | |
4 | 7 | |
5 | 8 | import org.springframework.stereotype.Repository; |
6 | 9 | |
... | ... | @@ -8,6 +11,7 @@ import br.com.centralit.api.dao.ContratoEventoDao; |
8 | 11 | import br.com.centralit.api.model.ContratoEvento; |
9 | 12 | import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; |
10 | 13 | import br.com.centralit.framework.dao.arquitetura.SearchSeven; |
14 | +import br.com.centralit.framework.util.UtilDate; | |
11 | 15 | |
12 | 16 | /** |
13 | 17 | * |
... | ... | @@ -68,4 +72,51 @@ public class ContratoEventoDaoHibernate extends CitGenericDAOImpl implements Con |
68 | 72 | |
69 | 73 | return this.search(search); |
70 | 74 | } |
75 | + | |
76 | + @SuppressWarnings("deprecation") | |
77 | + @Override | |
78 | + public Collection<ContratoEvento> findAllByContratoIntervalDataEmissao(Long contratoId, Date dataInicial, Date dateFinal) { | |
79 | + SearchSeven search = new SearchSeven(); | |
80 | + | |
81 | + search.addFilterIn("contrato.id", contratoId); | |
82 | + if(dataInicial != null){ | |
83 | + search.addFilterGreaterOrEqual("dataEvento", UtilDate.dateToCalendar(dataInicial)); | |
84 | + } | |
85 | + if(dateFinal != null){ | |
86 | + dateFinal.setHours(23); | |
87 | + dateFinal.setMinutes(59); | |
88 | + dateFinal.setSeconds(59); | |
89 | + search.addFilterLessOrEqual("dataEvento", UtilDate.dateToCalendar(dateFinal)); | |
90 | + } | |
91 | + | |
92 | + search.addSort("tipoEvento.descricao", false); | |
93 | + search.addSort("dataEvento", false); | |
94 | + | |
95 | + return this.search(search); | |
96 | + } | |
97 | + | |
98 | + @SuppressWarnings("deprecation") | |
99 | + @Override | |
100 | + public Collection<ContratoEvento> findAllByContratoTipoTermoDataEmissao(List<Long> codigosTermo, Date dataInicial, Date dateFinal) { | |
101 | + | |
102 | + SearchSeven search = new SearchSeven(); | |
103 | + | |
104 | + search.addFilterIn("tipoEvento.codigo", codigosTermo); | |
105 | + | |
106 | + if(dataInicial != null){ | |
107 | + search.addFilterGreaterOrEqual("dataEvento", UtilDate.dateToCalendar(dataInicial)); | |
108 | + } | |
109 | + | |
110 | + if(dateFinal != null){ | |
111 | + dateFinal.setHours(23); | |
112 | + dateFinal.setMinutes(59); | |
113 | + dateFinal.setSeconds(59); | |
114 | + search.addFilterLessOrEqual("dataEvento", UtilDate.dateToCalendar(dateFinal)); | |
115 | + } | |
116 | + | |
117 | + search.addSort("tipoEvento.descricao", false); | |
118 | + search.addSort("dataEvento", false); | |
119 | + | |
120 | + return this.search(search); | |
121 | + } | |
71 | 122 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/ContratoEmpenhoService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | +import java.sql.Connection; | |
3 | 4 | import java.util.Collection; |
4 | 5 | |
5 | 6 | import javax.servlet.http.HttpServletResponse; |
6 | 7 | |
8 | +import net.sf.jasperreports.engine.JRException; | |
9 | +import net.sf.jasperreports.engine.JasperPrint; | |
7 | 10 | import br.com.centralit.api.model.ContratoEmpenho; |
11 | +import br.com.centralit.framework.model.Usuario; | |
8 | 12 | import br.com.centralit.framework.service.arquitetura.GenericService; |
9 | 13 | |
10 | 14 | public interface ContratoEmpenhoService extends GenericService<ContratoEmpenho, Long> { |
11 | - | |
15 | + | |
12 | 16 | /** |
13 | - * | |
17 | + * | |
14 | 18 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
15 | 19 | * |
16 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
20 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
17 | 21 | * |
18 | 22 | * Método responsável por |
19 | 23 | * |
... | ... | @@ -28,4 +32,6 @@ public interface ContratoEmpenhoService extends GenericService<ContratoEmpenho, |
28 | 32 | |
29 | 33 | Collection<ContratoEmpenho> findEmpenhoParaLiberacao(Long contratoId); |
30 | 34 | |
35 | + JasperPrint getJasperPrintEmpenho(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException; | |
36 | + | |
31 | 37 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/ContratoEventoService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | 3 | import java.util.Collection; |
4 | +import java.util.Date; | |
5 | + | |
6 | +import javax.servlet.http.HttpServletResponse; | |
4 | 7 | |
5 | 8 | import br.com.centralit.api.model.ContratoEvento; |
6 | 9 | import br.com.centralit.framework.service.arquitetura.GenericService; |
... | ... | @@ -46,4 +49,10 @@ public interface ContratoEventoService extends GenericService<ContratoEvento, Lo |
46 | 49 | Boolean removeEventoContrato(String justificativaRemocao, Long idEvento); |
47 | 50 | |
48 | 51 | Collection<ContratoEvento> findAllByContratoTipoEvento(Long contratoId, String tipoEvento); |
52 | + | |
53 | + Collection<ContratoEvento> findAllByContratoIntervalDataEmissao(Long contratoId, Date dataInicial, Date dateFinal); | |
54 | + | |
55 | + void gerarTermos(Long[] arrayLong, boolean download,HttpServletResponse response); | |
56 | + | |
57 | + Collection<ContratoEvento> findAllByContratoTipoTermoDataEmissao(Long[] codigosTermo,Date dataInicial, Date dateFinal); | |
49 | 58 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/EventoAditivoService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | +import java.io.InputStream; | |
4 | +import java.sql.Connection; | |
3 | 5 | import java.util.Collection; |
4 | 6 | |
7 | +import net.sf.jasperreports.engine.JRException; | |
8 | +import net.sf.jasperreports.engine.JasperPrint; | |
5 | 9 | import br.com.centralit.api.model.EventoAditivo; |
10 | +import br.com.centralit.framework.model.Usuario; | |
6 | 11 | import br.com.centralit.framework.service.arquitetura.GenericService; |
7 | 12 | |
8 | 13 | public interface EventoAditivoService extends GenericService<EventoAditivo, Long> { |
9 | 14 | |
10 | 15 | /** |
11 | - * | |
16 | + * | |
12 | 17 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
13 | 18 | * |
14 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
19 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
15 | 20 | * |
16 | 21 | * Método responsável por |
17 | 22 | * |
... | ... | @@ -21,4 +26,6 @@ public interface EventoAditivoService extends GenericService<EventoAditivo, Long |
21 | 26 | * @return |
22 | 27 | */ |
23 | 28 | Collection<EventoAditivo> findAllByContrato(Long contratoId); |
29 | + | |
30 | + JasperPrint getJasperPrintAditivo(Long idAditivo, Connection conn, Usuario user, String titulo) throws JRException; | |
24 | 31 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/EventoApostilamentoService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | +import java.io.InputStream; | |
4 | +import java.sql.Connection; | |
5 | + | |
3 | 6 | import javax.servlet.http.HttpServletResponse; |
4 | 7 | |
8 | +import net.sf.jasperreports.engine.JRException; | |
9 | +import net.sf.jasperreports.engine.JasperPrint; | |
5 | 10 | import br.com.centralit.api.model.EventoApostilamento; |
11 | +import br.com.centralit.framework.model.Usuario; | |
6 | 12 | import br.com.centralit.framework.service.arquitetura.GenericService; |
7 | 13 | |
8 | 14 | |
... | ... | @@ -30,4 +36,6 @@ public interface EventoApostilamentoService extends GenericService<EventoApostil |
30 | 36 | */ |
31 | 37 | void gerarPdfApostilamento(Long idApostilamento, boolean download, HttpServletResponse response); |
32 | 38 | |
39 | + JasperPrint getJasperPrintApostilamento(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException; | |
40 | + | |
33 | 41 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/EventoRecebimentoObjetoService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | +import java.sql.Connection; | |
4 | + | |
3 | 5 | import javax.servlet.http.HttpServletResponse; |
4 | 6 | |
7 | +import net.sf.jasperreports.engine.JRException; | |
8 | +import net.sf.jasperreports.engine.JasperPrint; | |
5 | 9 | import br.com.centralit.api.model.EventoRecebimentoObjeto; |
10 | +import br.com.centralit.framework.model.Usuario; | |
6 | 11 | import br.com.centralit.framework.service.arquitetura.GenericService; |
7 | 12 | |
8 | 13 | public interface EventoRecebimentoObjetoService extends GenericService<EventoRecebimentoObjeto, Long> { |
... | ... | @@ -19,4 +24,6 @@ public interface EventoRecebimentoObjetoService extends GenericService<EventoRec |
19 | 24 | */ |
20 | 25 | void gerarPdfRecebimento(Long idRecebimento, boolean download, HttpServletResponse response); |
21 | 26 | |
27 | + JasperPrint getJasperPrintRecebimentoObjeto(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException; | |
28 | + | |
22 | 29 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/EventoRepactuacaoService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | +import java.sql.Connection; | |
4 | + | |
5 | +import net.sf.jasperreports.engine.JRException; | |
6 | +import net.sf.jasperreports.engine.JasperPrint; | |
3 | 7 | import br.com.centralit.api.model.EventoRepactuacao; |
8 | +import br.com.centralit.framework.model.Usuario; | |
4 | 9 | import br.com.centralit.framework.service.arquitetura.GenericService; |
5 | 10 | |
6 | 11 | |
7 | 12 | /** |
8 | - * | |
13 | + * | |
9 | 14 | * <p><img src="http://centralit.com.br/images/logo_central.png"></p> |
10 | 15 | * |
11 | 16 | * <p><b>Company: </b> Central IT - Governança Corporativa - </p> |
... | ... | @@ -13,11 +18,11 @@ import br.com.centralit.framework.service.arquitetura.GenericService; |
13 | 18 | * <p><b>Title: </b></p> |
14 | 19 | * |
15 | 20 | * <p><b>Description: </b></p> |
16 | - * | |
21 | + * | |
17 | 22 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
18 | 23 | * |
19 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
20 | - * | |
24 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
25 | + * | |
21 | 26 | * @since 19/03/2016 - 09:20:20 |
22 | 27 | * |
23 | 28 | * @version 1.0.0 |
... | ... | @@ -27,4 +32,6 @@ import br.com.centralit.framework.service.arquitetura.GenericService; |
27 | 32 | */ |
28 | 33 | public interface EventoRepactuacaoService extends GenericService<EventoRepactuacao, Long> { |
29 | 34 | |
35 | + JasperPrint getJasperPrintRepactuacao(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException; | |
36 | + | |
30 | 37 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/EventoRescisaoContratoService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | +import java.sql.Connection; | |
4 | + | |
3 | 5 | import javax.servlet.http.HttpServletResponse; |
4 | 6 | |
7 | +import net.sf.jasperreports.engine.JRException; | |
8 | +import net.sf.jasperreports.engine.JasperPrint; | |
5 | 9 | import br.com.centralit.api.model.EventoRescisaoContrato; |
10 | +import br.com.centralit.framework.model.Usuario; | |
6 | 11 | import br.com.centralit.framework.service.arquitetura.GenericService; |
7 | 12 | |
8 | 13 | public interface EventoRescisaoContratoService extends GenericService<EventoRescisaoContrato, Long> { |
9 | 14 | |
10 | 15 | void gerarPdfTermo(Long idRescisaoContrato, boolean download,HttpServletResponse response); |
11 | 16 | |
17 | + JasperPrint getJasperPrintRescisao(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException; | |
18 | + | |
12 | 19 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/ContratoEmpenhoServiceImpl.java
... | ... | @@ -47,7 +47,7 @@ import net.sf.jasperreports.engine.design.JasperDesign; |
47 | 47 | import net.sf.jasperreports.engine.xml.JRXmlLoader; |
48 | 48 | |
49 | 49 | /** |
50 | - * | |
50 | + * | |
51 | 51 | * <p><img src="http://centralit.com.br/images/logo_central.png"></p> |
52 | 52 | * |
53 | 53 | * <p><b>Company: </b> Central IT - Governança Corporativa - </p> |
... | ... | @@ -55,11 +55,11 @@ import net.sf.jasperreports.engine.xml.JRXmlLoader; |
55 | 55 | * <p><b>Title: </b></p> |
56 | 56 | * |
57 | 57 | * <p><b>Description: </b></p> |
58 | - * | |
58 | + * | |
59 | 59 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
60 | 60 | * |
61 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
62 | - * | |
61 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
62 | + * | |
63 | 63 | * @since 09/03/2016 - 11:46:17 |
64 | 64 | * |
65 | 65 | * @version 1.0.0 |
... | ... | @@ -74,24 +74,24 @@ public class ContratoEmpenhoServiceImpl extends GenericServiceImpl<ContratoEmpen |
74 | 74 | |
75 | 75 | @Autowired |
76 | 76 | private ContratoService contratoService; |
77 | - | |
77 | + | |
78 | 78 | @Autowired |
79 | 79 | private AnexoService anexoService; |
80 | 80 | |
81 | 81 | @Autowired |
82 | 82 | private UsuarioService usuarioService; |
83 | - | |
83 | + | |
84 | 84 | @Autowired |
85 | 85 | private DominioService dominioService; |
86 | - | |
86 | + | |
87 | 87 | @Autowired |
88 | 88 | private InternacionalizacaoService internacionalizacaoService; |
89 | - | |
89 | + | |
90 | 90 | @Autowired |
91 | 91 | private ParceiroService parceiroServiceFornecedor; |
92 | - | |
92 | + | |
93 | 93 | private Dominio idioma; |
94 | - | |
94 | + | |
95 | 95 | @Autowired |
96 | 96 | private ReportController reportService; |
97 | 97 | |
... | ... | @@ -100,22 +100,22 @@ public class ContratoEmpenhoServiceImpl extends GenericServiceImpl<ContratoEmpen |
100 | 100 | this.dao = contratoEmpenhoDao; |
101 | 101 | this.contratoEmpenhoDao = contratoEmpenhoDao; |
102 | 102 | } |
103 | - | |
103 | + | |
104 | 104 | public ContratoEmpenho save(ContratoEmpenho entity) { |
105 | - | |
105 | + | |
106 | 106 | entity.setDataEvento(entity.getData()); |
107 | 107 | String descricaoEmpenho = this.internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EMPENHO", getIdioma()); |
108 | 108 | descricaoEmpenho = descricaoEmpenho.replace(":VALOR:", Util.convertBigDecimalToString(entity.getValorEmpenhado())); |
109 | 109 | descricaoEmpenho = descricaoEmpenho.replace(":DATAEVENTO:", UtilDate.formatarData(entity.getData().getTime(), "dd/MM/yyyy")); |
110 | 110 | entity.setDescricao(descricaoEmpenho); |
111 | - | |
111 | + | |
112 | 112 | entity.setTipoEvento(this.dominioService.findByChaveAndCodigo(DominioContrato.TIPO_EVENTO_CONTRATO, DominioContrato.TIPO_EVENTO_EMPENHO)); |
113 | 113 | |
114 | 114 | this.montarDocsObs(entity); |
115 | 115 | ContratoEmpenho entitySaved = super.save(entity); |
116 | 116 | return entitySaved; |
117 | 117 | } |
118 | - | |
118 | + | |
119 | 119 | private void montarDocsObs(ContratoEmpenho entity) { |
120 | 120 | |
121 | 121 | if (!UtilColecao.isVazio(entity.getObservacoes())) { |
... | ... | @@ -165,12 +165,12 @@ public class ContratoEmpenhoServiceImpl extends GenericServiceImpl<ContratoEmpen |
165 | 165 | public Collection<ContratoEmpenho> findAllByContrato(Long contratoId) { |
166 | 166 | return this.contratoEmpenhoDao.findAllByContrato(contratoId); |
167 | 167 | } |
168 | - | |
168 | + | |
169 | 169 | @Override |
170 | 170 | public Collection<ContratoEmpenho> findEmpenhoParaLiberacao(Long contratoId) { |
171 | 171 | return this.contratoEmpenhoDao.findEmpenhoParaLiberacao(contratoId); |
172 | 172 | } |
173 | - | |
173 | + | |
174 | 174 | public Dominio getIdioma() { |
175 | 175 | if(!UtilObjeto.isReferencia(idioma)){ |
176 | 176 | idioma = this.dominioService.findByChaveAndCodigo("tipoIdioma", Dominio.TIPO_IDIOMA_PT_BR_CODIGO); |
... | ... | @@ -188,10 +188,27 @@ public class ContratoEmpenhoServiceImpl extends GenericServiceImpl<ContratoEmpen |
188 | 188 | try { |
189 | 189 | conn = reportService.getConnection(); |
190 | 190 | Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); |
191 | + String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_DOCUMENTO_EMPENHO", this.getIdioma()); | |
192 | + | |
193 | + // Responsavel por verificar a presenca de dados no relatorio | |
194 | + reportService.gerarRelatorio(download, "pdf", this.getJasperPrintEmpenho(idEmpenho, conn, usuarioLogado, titulo), response, baos, titulo); | |
195 | + | |
196 | + } catch (JRException jre) { | |
197 | + throw new RuntimeException(jre); | |
198 | + } catch (Exception e) { | |
199 | + throw new BusinessException(); | |
200 | + } finally { | |
201 | + UtilDataBase.closeResources(conn, input, inputSub, baos); | |
202 | + } | |
203 | + } | |
191 | 204 | |
205 | + @Override | |
206 | + public JasperPrint getJasperPrintEmpenho(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException { | |
207 | + InputStream inputSub = null; | |
208 | + InputStream input = null; | |
209 | + try { | |
192 | 210 | input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); |
193 | 211 | inputSub = this.getClass().getResourceAsStream("/reports/eventoEmpenho.jrxml"); |
194 | - String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_DOCUMENTO_EMPENHO", this.getIdioma()); | |
195 | 212 | |
196 | 213 | JasperDesign jasperDesign = JRXmlLoader.load(input); |
197 | 214 | JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); |
... | ... | @@ -199,7 +216,7 @@ public class ContratoEmpenhoServiceImpl extends GenericServiceImpl<ContratoEmpen |
199 | 216 | JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); |
200 | 217 | |
201 | 218 | Map<String, Object> subReportParameters = new HashMap<String, Object>(); |
202 | - subReportParameters.put("EMPENHO_ID", idEmpenho); | |
219 | + subReportParameters.put("EMPENHO_ID", id); | |
203 | 220 | |
204 | 221 | Map<String, Object> parameters = new HashMap<String, Object>(); |
205 | 222 | parameters.put("ORGANIZACAO_ID", usuarioLogado.getOrganizacao().getId()); |
... | ... | @@ -208,18 +225,10 @@ public class ContratoEmpenhoServiceImpl extends GenericServiceImpl<ContratoEmpen |
208 | 225 | parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); |
209 | 226 | parameters.put("REPORT_CONNECTION", conn); |
210 | 227 | |
211 | - JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); | |
212 | - | |
213 | - // Responsavel por verificar a presenca de dados no relatorio | |
214 | - reportService.gerarRelatorio(download, "pdf", jasperPrint, response, baos, titulo); | |
215 | - | |
216 | - } catch (JRException jre) { | |
217 | - throw new RuntimeException(jre); | |
218 | - } catch (Exception e) { | |
219 | - throw new BusinessException(); | |
220 | - } finally { | |
221 | - UtilDataBase.closeResources(conn, input, inputSub, baos); | |
228 | + return JasperFillManager.fillReport(jasperReport, parameters, conn); | |
229 | + } finally{ | |
230 | + UtilDataBase.closeResources(inputSub); | |
222 | 231 | } |
223 | 232 | } |
224 | - | |
233 | + | |
225 | 234 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/ContratoEventoServiceImpl.java
1 | 1 | package br.com.centralit.api.service.impl; |
2 | 2 | |
3 | +import java.io.ByteArrayOutputStream; | |
4 | +import java.io.InputStream; | |
5 | +import java.sql.Connection; | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.Arrays; | |
3 | 8 | import java.util.Collection; |
9 | +import java.util.Date; | |
10 | +import java.util.List; | |
11 | + | |
12 | +import javax.servlet.http.HttpServletResponse; | |
13 | + | |
14 | +import net.sf.jasperreports.engine.JRException; | |
15 | +import net.sf.jasperreports.engine.JRPrintPage; | |
16 | +import net.sf.jasperreports.engine.JasperPrint; | |
4 | 17 | |
5 | 18 | import org.apache.commons.lang3.StringUtils; |
6 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
20 | +import org.springframework.security.core.context.SecurityContextHolder; | |
7 | 21 | import org.springframework.stereotype.Service; |
8 | 22 | |
9 | 23 | import br.com.centralit.api.dao.ContratoEventoDao; |
10 | 24 | import br.com.centralit.api.model.ContratoEvento; |
11 | 25 | import br.com.centralit.api.model.DominioContrato; |
12 | 26 | import br.com.centralit.api.model.EventoAditivo; |
13 | -import br.com.centralit.api.model.DominioContrato; | |
27 | +import br.com.centralit.api.service.ContratoEmpenhoService; | |
14 | 28 | import br.com.centralit.api.service.ContratoEventoService; |
15 | 29 | import br.com.centralit.api.service.DominioService; |
16 | 30 | import br.com.centralit.api.service.EventoAditivoService; |
31 | +import br.com.centralit.api.service.EventoApostilamentoService; | |
32 | +import br.com.centralit.api.service.EventoRecebimentoObjetoService; | |
33 | +import br.com.centralit.api.service.EventoRepactuacaoService; | |
34 | +import br.com.centralit.api.service.EventoRescisaoContratoService; | |
17 | 35 | import br.com.centralit.api.service.InternacionalizacaoService; |
36 | +import br.com.centralit.api.service.UsuarioService; | |
37 | +import br.com.centralit.framework.controller.ReportController; | |
18 | 38 | import br.com.centralit.framework.exception.BusinessException; |
19 | 39 | import br.com.centralit.framework.model.Dominio; |
40 | +import br.com.centralit.framework.model.Usuario; | |
20 | 41 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
42 | +import br.com.centralit.framework.util.UtilColecao; | |
43 | +import br.com.centralit.framework.util.UtilDataBase; | |
21 | 44 | import br.com.centralit.framework.util.UtilObjeto; |
22 | 45 | |
23 | 46 | /** |
... | ... | @@ -49,13 +72,37 @@ public class ContratoEventoServiceImpl extends GenericServiceImpl<ContratoEvento |
49 | 72 | |
50 | 73 | @Autowired |
51 | 74 | private InternacionalizacaoService internacionalizacaoService; |
52 | - | |
75 | + | |
53 | 76 | @Autowired |
54 | 77 | private EventoAditivoService eventoAditivoService; |
55 | 78 | |
56 | 79 | @Autowired |
57 | 80 | private DominioService dominioService; |
58 | 81 | |
82 | + @Autowired | |
83 | + private ReportController reportService; | |
84 | + | |
85 | + @Autowired | |
86 | + private UsuarioService usuarioService; | |
87 | + | |
88 | + @Autowired | |
89 | + private EventoAditivoService aditivoService; | |
90 | + | |
91 | + @Autowired | |
92 | + private EventoRepactuacaoService repactuacaoService; | |
93 | + | |
94 | + @Autowired | |
95 | + private EventoRescisaoContratoService rescisaoContratoService; | |
96 | + | |
97 | + @Autowired | |
98 | + private EventoRecebimentoObjetoService recebimentoObjetoService; | |
99 | + | |
100 | + @Autowired | |
101 | + private ContratoEmpenhoService contratoEmpenhoService; | |
102 | + | |
103 | + @Autowired | |
104 | + private EventoApostilamentoService apostilamentoService; | |
105 | + | |
59 | 106 | private Dominio idioma; |
60 | 107 | |
61 | 108 | /** |
... | ... | @@ -82,14 +129,14 @@ public class ContratoEventoServiceImpl extends GenericServiceImpl<ContratoEvento |
82 | 129 | throw new BusinessException(this.internacionalizacaoService.getTranslate("MSG.MN001", this.getIdioma())); |
83 | 130 | } |
84 | 131 | ContratoEvento contratoEvento = this.find(idEvento); |
85 | - | |
132 | + | |
86 | 133 | if (contratoEvento instanceof EventoAditivo) { |
87 | 134 | EventoAditivo aditivo = (EventoAditivo) contratoEvento; |
88 | 135 | aditivo.setContratoAditivoInativo(aditivo.getContratoAditivo()); |
89 | 136 | aditivo.setContratoAditivo(null); |
90 | 137 | this.eventoAditivoService.remove(aditivo); |
91 | 138 | } |
92 | - | |
139 | + | |
93 | 140 | contratoEvento.setJustificativaExclusao(justificativaRemocao); |
94 | 141 | contratoEvento.setContratoInativo(contratoEvento.getContrato()); |
95 | 142 | contratoEvento.setContrato(null); |
... | ... | @@ -109,4 +156,94 @@ public class ContratoEventoServiceImpl extends GenericServiceImpl<ContratoEvento |
109 | 156 | return this.contratoEventoDao.findAllByContratoTipoEvento(contratoId, this.dominioService.findByChaveAndNome(DominioContrato.TIPO_EVENTO_CONTRATO, tipoEvento).getId()); |
110 | 157 | } |
111 | 158 | |
159 | + @Override | |
160 | + public Collection<ContratoEvento> findAllByContratoIntervalDataEmissao(Long contratoId, Date dataInicial, Date dateFinal) { | |
161 | + return this.contratoEventoDao.findAllByContratoIntervalDataEmissao(contratoId, dataInicial, dateFinal); | |
162 | + } | |
163 | + | |
164 | + @Override | |
165 | + public void gerarTermos(Long[] arrayLong, boolean download, HttpServletResponse response) { | |
166 | + | |
167 | + Connection conn = null; | |
168 | + ByteArrayOutputStream baos = null; | |
169 | + InputStream inputCabecalho = null; | |
170 | + JasperPrint jasperPrint = null; | |
171 | + | |
172 | + try { | |
173 | + conn = reportService.getConnection(); | |
174 | + | |
175 | + Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); | |
176 | + | |
177 | + List<JasperPrint> jasperPrints = new ArrayList<JasperPrint>(); | |
178 | + JasperPrint jasperPrincipal = new JasperPrint(); | |
179 | + | |
180 | + if (UtilObjeto.isReferencia(arrayLong)){ | |
181 | + Integer index = 1; | |
182 | + for (Long idEvento : arrayLong) { | |
183 | + ContratoEvento evento = this.find(idEvento); | |
184 | + | |
185 | + if(evento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_ADITIVO){ | |
186 | + String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_RELATORIO_ADITIVO", this.getIdioma()); | |
187 | + jasperPrint = this.aditivoService.getJasperPrintAditivo(evento.getId(), conn, usuarioLogado, titulo); | |
188 | + | |
189 | + }else if(evento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_APOSTILAMENTO){ | |
190 | + String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_DOCUMENTO_APOSTILAMENTO", this.getIdioma()); | |
191 | + jasperPrint = this.apostilamentoService.getJasperPrintApostilamento(evento.getId(), conn, usuarioLogado, titulo); | |
192 | + | |
193 | + }else if(evento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_EMPENHO){ | |
194 | + String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_DOCUMENTO_EMPENHO", this.getIdioma()); | |
195 | + jasperPrint = this.contratoEmpenhoService.getJasperPrintEmpenho(evento.getId(), conn, usuarioLogado, titulo); | |
196 | + | |
197 | + }else if(evento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_RECEBIMENTO_OBJETO){ | |
198 | + String titulo = this.internacionalizacaoService.getTranslate("LABEL.TITULO_DOCUMENTO_RECEBIMENTO", this.getIdioma()); | |
199 | + jasperPrint = this.recebimentoObjetoService.getJasperPrintRecebimentoObjeto(evento.getId(), conn, usuarioLogado, titulo); | |
200 | + | |
201 | + }else if(evento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_REPACTUACAO){ | |
202 | + String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_RELATORIO_REPACTUACAO", this.getIdioma()); | |
203 | + jasperPrint = this.repactuacaoService.getJasperPrintRepactuacao(evento.getId(), conn, usuarioLogado, titulo); | |
204 | + | |
205 | + }else if(evento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_RESCISAO){ | |
206 | + String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_DOCUMENTO_RESCISAO_CONTRATO", this.getIdioma()); | |
207 | + jasperPrint = this.rescisaoContratoService.getJasperPrintRescisao(evento.getId(), conn, usuarioLogado, titulo); | |
208 | + } | |
209 | + | |
210 | + jasperPrincipal = addJasperPrint(jasperPrint,jasperPrints, jasperPrincipal,index); | |
211 | + index ++; | |
212 | + continue; | |
213 | + | |
214 | + } | |
215 | + if (!UtilColecao.isVazio(jasperPrints)){ | |
216 | + for (JasperPrint jasper : jasperPrints) { | |
217 | + for (int j = 0; j < jasper.getPages().size(); j++) { | |
218 | + JRPrintPage object = (JRPrintPage) jasper.getPages().get(j); | |
219 | + jasperPrincipal.addPage(object); | |
220 | + } | |
221 | + } | |
222 | + | |
223 | + } | |
224 | + reportService.gerarRelatorio(download, "pdf", jasperPrincipal, response, baos, ""); | |
225 | + } | |
226 | + | |
227 | + } catch (JRException jre) { | |
228 | + throw new RuntimeException(jre); | |
229 | + } finally { | |
230 | + UtilDataBase.closeResources(conn, inputCabecalho, baos); | |
231 | + } | |
232 | + | |
233 | + } | |
234 | + | |
235 | + private JasperPrint addJasperPrint(JasperPrint jasperPrint,List<JasperPrint> jasperPrints,JasperPrint jasperPrincipal, Integer index) { | |
236 | + if(index.equals(1)){ | |
237 | + jasperPrincipal = jasperPrint; | |
238 | + } else { | |
239 | + jasperPrints.add(jasperPrint); | |
240 | + } | |
241 | + return jasperPrincipal; | |
242 | + } | |
243 | + | |
244 | + @Override | |
245 | + public Collection<ContratoEvento> findAllByContratoTipoTermoDataEmissao(Long[] codigosTermo, Date dataInicial, Date dateFinal) { | |
246 | + return this.contratoEventoDao.findAllByContratoTipoTermoDataEmissao(Arrays.asList(codigosTermo), dataInicial, dateFinal); | |
247 | + } | |
248 | + | |
112 | 249 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EventoAditivoServiceImpl.java
1 | 1 | package br.com.centralit.api.service.impl; |
2 | 2 | |
3 | +import java.io.InputStream; | |
4 | +import java.sql.Connection; | |
3 | 5 | import java.text.DecimalFormat; |
4 | 6 | import java.text.SimpleDateFormat; |
5 | 7 | import java.util.Calendar; |
6 | 8 | import java.util.Collection; |
9 | +import java.util.HashMap; | |
10 | +import java.util.Map; | |
11 | + | |
12 | +import net.sf.jasperreports.engine.JRException; | |
13 | +import net.sf.jasperreports.engine.JasperCompileManager; | |
14 | +import net.sf.jasperreports.engine.JasperFillManager; | |
15 | +import net.sf.jasperreports.engine.JasperPrint; | |
16 | +import net.sf.jasperreports.engine.JasperReport; | |
17 | +import net.sf.jasperreports.engine.design.JasperDesign; | |
18 | +import net.sf.jasperreports.engine.xml.JRXmlLoader; | |
7 | 19 | |
8 | 20 | import org.apache.commons.collections.CollectionUtils; |
9 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -24,12 +36,14 @@ import br.com.centralit.api.service.InternacionalizacaoService; |
24 | 36 | import br.com.centralit.api.service.ParceiroService; |
25 | 37 | import br.com.centralit.api.service.UsuarioService; |
26 | 38 | import br.com.centralit.framework.model.Dominio; |
39 | +import br.com.centralit.framework.model.Usuario; | |
27 | 40 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
28 | 41 | import br.com.centralit.framework.util.Util; |
42 | +import br.com.centralit.framework.util.UtilDataBase; | |
29 | 43 | import br.com.centralit.framework.util.UtilObjeto; |
30 | 44 | |
31 | 45 | /** |
32 | - * | |
46 | + * | |
33 | 47 | * <p><img src="http://centralit.com.br/images/logo_central.png"></p> |
34 | 48 | * |
35 | 49 | * <p><b>Company: </b> Central IT - Governança Corporativa - </p> |
... | ... | @@ -37,11 +51,11 @@ import br.com.centralit.framework.util.UtilObjeto; |
37 | 51 | * <p><b>Title: </b></p> |
38 | 52 | * |
39 | 53 | * <p><b>Description: </b></p> |
40 | - * | |
54 | + * | |
41 | 55 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
42 | 56 | * |
43 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
44 | - * | |
57 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
58 | + * | |
45 | 59 | * @since 15/03/2016 - 18:33:28 |
46 | 60 | * |
47 | 61 | * @version 1.0.0 |
... | ... | @@ -53,44 +67,44 @@ import br.com.centralit.framework.util.UtilObjeto; |
53 | 67 | public class EventoAditivoServiceImpl extends GenericServiceImpl<EventoAditivo, Long> implements EventoAditivoService { |
54 | 68 | |
55 | 69 | private EventoAditivoDao eventoAditivoDao; |
56 | - | |
70 | + | |
57 | 71 | @Autowired |
58 | 72 | private ContratoService contratoService; |
59 | - | |
73 | + | |
60 | 74 | @Autowired |
61 | 75 | private InternacionalizacaoService internacionalizacaoService; |
62 | - | |
76 | + | |
63 | 77 | @Autowired |
64 | 78 | private DominioService dominioService; |
65 | - | |
79 | + | |
66 | 80 | @Autowired |
67 | 81 | private UsuarioService usuarioService; |
68 | - | |
82 | + | |
69 | 83 | @Autowired |
70 | 84 | private ParceiroService parceiroService; |
71 | - | |
85 | + | |
72 | 86 | private Dominio idioma; |
73 | 87 | |
74 | 88 | @Autowired |
75 | 89 | public EventoAditivoServiceImpl(EventoAditivoDao aditivoDao, @Qualifier("eventoAditivoValidator") Validator validator) { |
76 | 90 | |
77 | 91 | this.dao = aditivoDao; |
78 | - | |
92 | + | |
79 | 93 | this.eventoAditivoDao = aditivoDao; |
80 | - | |
94 | + | |
81 | 95 | this.validator = validator; |
82 | 96 | } |
83 | 97 | |
84 | 98 | public EventoAditivo save(EventoAditivo entity) { |
85 | 99 | montarObjeto(entity); |
86 | - | |
100 | + | |
87 | 101 | // realiza a validação do objeto com a classe EventoAditivoValidator.java |
88 | 102 | this.validarEntidade(entity, this.validator); |
89 | - | |
103 | + | |
90 | 104 | EventoAditivo entitySaved = super.save(entity); |
91 | 105 | return entitySaved; |
92 | 106 | } |
93 | - | |
107 | + | |
94 | 108 | private void gerarNumeroSequencial(EventoAditivo entity) { |
95 | 109 | |
96 | 110 | // busca todos os registros dentro do ano de emissao e ordena decrescente pelo numeroSequencial. |
... | ... | @@ -117,11 +131,11 @@ public class EventoAditivoServiceImpl extends GenericServiceImpl<EventoAditivo, |
117 | 131 | montarObjeto(aditivo); |
118 | 132 | // realiza a validação do objeto com a classe EventoAditivoValidator.java |
119 | 133 | this.validarEntidade(aditivo, this.validator); |
120 | - | |
134 | + | |
121 | 135 | super.save(aditivo); |
122 | 136 | return aditivo; |
123 | 137 | } |
124 | - | |
138 | + | |
125 | 139 | private void montarObjeto(EventoAditivo eventoAditivo) { |
126 | 140 | |
127 | 141 | if (eventoAditivo.getOrganizacao() == null) { |
... | ... | @@ -135,31 +149,31 @@ public class EventoAditivoServiceImpl extends GenericServiceImpl<EventoAditivo, |
135 | 149 | eventoAditivo.setContrato(this.contratoService.find(eventoAditivo.getContrato().getId())); |
136 | 150 | eventoAditivo.setContratoAditivo(this.contratoService.find(eventoAditivo.getContrato().getId())); |
137 | 151 | eventoAditivo.setTipoAlteracao(this.dominioService.find(eventoAditivo.getTipoAlteracao().getId())); |
138 | - | |
152 | + | |
139 | 153 | if (UtilObjeto.isReferencia(eventoAditivo.getTipoAlteracaoValor())) { |
140 | 154 | eventoAditivo.setTipoAlteracaoValor(this.dominioService.findByChaveAndCodigo(DominioContrato.TIPO_ALTERACAO_VALOR, eventoAditivo.getTipoAlteracaoValor().getCodigo())); |
141 | 155 | } |
142 | - | |
156 | + | |
143 | 157 | eventoAditivo.setDataEvento(eventoAditivo.getDataEmissao()); |
144 | - | |
158 | + | |
145 | 159 | SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
146 | - | |
160 | + | |
147 | 161 | String sequencialAno = eventoAditivo.getRegistroSequencial().getSequencialAno(); |
148 | 162 | String sequencialAnoFormatado = sequencialAno.substring(0, sequencialAno.length() - 4).concat("/").concat(sequencialAno.substring(sequencialAno.length() - 4)); |
149 | - | |
163 | + | |
150 | 164 | String descricaoEventoAditivo = this.internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EVENTO_ADITIVO", this.getIdioma()); |
151 | 165 | descricaoEventoAditivo = String.format(descricaoEventoAditivo, sequencialAnoFormatado, sdf.format(eventoAditivo.getDataEmissao().getTime())); |
152 | - | |
166 | + | |
153 | 167 | if (eventoAditivo.getAditivoDePrazo()) { |
154 | 168 | descricaoEventoAditivo = descricaoEventoAditivo.concat(this.internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EVENTO_ADITIVO_PRAZO", this.getIdioma())); |
155 | 169 | descricaoEventoAditivo = String.format(descricaoEventoAditivo, sdf.format(eventoAditivo.getDataInicio().getTime()), sdf.format(eventoAditivo.getDataFim().getTime())); |
156 | 170 | } |
157 | - | |
171 | + | |
158 | 172 | if (eventoAditivo.getAditivoDeValor()) { |
159 | 173 | descricaoEventoAditivo = descricaoEventoAditivo.concat(this.internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EVENTO_ADITIVO_VALOR", this.getIdioma())); |
160 | 174 | descricaoEventoAditivo = String.format(descricaoEventoAditivo, eventoAditivo.getTipoAlteracaoValor().getDescricao(), Util.convertBigDecimalToString(eventoAditivo.getValorAditivo())); |
161 | 175 | } |
162 | - | |
176 | + | |
163 | 177 | if (eventoAditivo.getAditivoDeClausula()) { |
164 | 178 | descricaoEventoAditivo = descricaoEventoAditivo.concat(this.internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EVENTO_ADITIVO_CLAUSULA", this.getIdioma())); |
165 | 179 | } |
... | ... | @@ -205,7 +219,7 @@ public class EventoAditivoServiceImpl extends GenericServiceImpl<EventoAditivo, |
205 | 219 | public Collection<EventoAditivo> findAllByContrato(Long contratoId) { |
206 | 220 | return this.eventoAditivoDao.findAllByContrato(contratoId); |
207 | 221 | } |
208 | - | |
222 | + | |
209 | 223 | private Dominio getIdioma() { |
210 | 224 | if(!UtilObjeto.isReferencia(idioma)){ |
211 | 225 | idioma = this.dominioService.findByChaveAndCodigo("tipoIdioma", Dominio.TIPO_IDIOMA_PT_BR_CODIGO); |
... | ... | @@ -213,4 +227,34 @@ public class EventoAditivoServiceImpl extends GenericServiceImpl<EventoAditivo, |
213 | 227 | return idioma; |
214 | 228 | } |
215 | 229 | |
230 | + public JasperPrint getJasperPrintAditivo(Long idAditivo, Connection conn, Usuario user, String titulo) throws JRException { | |
231 | + InputStream inputSub = null; | |
232 | + InputStream input = null; | |
233 | + try { | |
234 | + input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); | |
235 | + inputSub = this.getClass().getResourceAsStream("/reports/eventoAditivo.jrxml"); | |
236 | + | |
237 | + JasperDesign jasperDesign = JRXmlLoader.load(input); | |
238 | + JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); | |
239 | + | |
240 | + JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); | |
241 | + JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); | |
242 | + | |
243 | + Map<String, Object> subReportParameters = new HashMap<String, Object>(); | |
244 | + subReportParameters.put("ADITIVO_ID", idAditivo); | |
245 | + subReportParameters.put("REPORT_CONNECTION", conn); | |
246 | + | |
247 | + Map<String, Object> parameters = new HashMap<String, Object>(); | |
248 | + parameters.put("ORGANIZACAO_ID", user.getOrganizacao().getId()); | |
249 | + parameters.put("TITULO", titulo); | |
250 | + parameters.put("SUBREPORT_DIR", jasperReportSub); | |
251 | + parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); | |
252 | + parameters.put("REPORT_CONNECTION", conn); | |
253 | + | |
254 | + return JasperFillManager.fillReport(jasperReport, parameters, conn); | |
255 | + } finally{ | |
256 | + UtilDataBase.closeResources(inputSub); | |
257 | + } | |
258 | + } | |
259 | + | |
216 | 260 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EventoApostilamentoServiceImpl.java
... | ... | @@ -222,30 +222,10 @@ public class EventoApostilamentoServiceImpl extends GenericServiceImpl<EventoApo |
222 | 222 | try { |
223 | 223 | conn = reportService.getConnection(); |
224 | 224 | Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); |
225 | - | |
226 | - input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); | |
227 | - inputSub = this.getClass().getResourceAsStream("/reports/eventoApostilamento.jrxml"); | |
228 | 225 | String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_DOCUMENTO_APOSTILAMENTO", this.getIdioma()); |
229 | 226 | |
230 | - JasperDesign jasperDesign = JRXmlLoader.load(input); | |
231 | - JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); | |
232 | - JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); | |
233 | - JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); | |
234 | - | |
235 | - Map<String, Object> subReportParameters = new HashMap<String, Object>(); | |
236 | - subReportParameters.put("APOSTILAMENTO_ID", idApostilamento); | |
237 | - | |
238 | - Map<String, Object> parameters = new HashMap<String, Object>(); | |
239 | - parameters.put("ORGANIZACAO_ID", usuarioLogado.getOrganizacao().getId()); | |
240 | - parameters.put("TITULO", titulo); | |
241 | - parameters.put("SUBREPORT_DIR", jasperReportSub); | |
242 | - parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); | |
243 | - parameters.put("REPORT_CONNECTION", conn); | |
244 | - | |
245 | - JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); | |
246 | - | |
247 | 227 | // Responsavel por verificar a presenca de dados no relatorio |
248 | - reportService.gerarRelatorio(download, "pdf", jasperPrint, response, baos, titulo); | |
228 | + reportService.gerarRelatorio(download, "pdf", this.getJasperPrintApostilamento(idApostilamento, conn, usuarioLogado, titulo), response, baos, titulo); | |
249 | 229 | |
250 | 230 | } catch (JRException jre) { |
251 | 231 | LOG.info("N\u00e3o consegui gerar o relat\u00f3rio de apostilamento. Veja a exce\u00e7\u00e3o para identificar a causa", jre.getCause()); |
... | ... | @@ -263,4 +243,33 @@ public class EventoApostilamentoServiceImpl extends GenericServiceImpl<EventoApo |
263 | 243 | } |
264 | 244 | return idioma; |
265 | 245 | } |
246 | + | |
247 | + @Override | |
248 | + public JasperPrint getJasperPrintApostilamento(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException { | |
249 | + InputStream inputSub = null; | |
250 | + InputStream input = null; | |
251 | + try { | |
252 | + input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); | |
253 | + inputSub = this.getClass().getResourceAsStream("/reports/eventoApostilamento.jrxml"); | |
254 | + | |
255 | + JasperDesign jasperDesign = JRXmlLoader.load(input); | |
256 | + JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); | |
257 | + JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); | |
258 | + JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); | |
259 | + | |
260 | + Map<String, Object> subReportParameters = new HashMap<String, Object>(); | |
261 | + subReportParameters.put("APOSTILAMENTO_ID", id); | |
262 | + | |
263 | + Map<String, Object> parameters = new HashMap<String, Object>(); | |
264 | + parameters.put("ORGANIZACAO_ID", usuarioLogado.getOrganizacao().getId()); | |
265 | + parameters.put("TITULO", titulo); | |
266 | + parameters.put("SUBREPORT_DIR", jasperReportSub); | |
267 | + parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); | |
268 | + parameters.put("REPORT_CONNECTION", conn); | |
269 | + | |
270 | + return JasperFillManager.fillReport(jasperReport, parameters, conn); | |
271 | + } finally{ | |
272 | + UtilDataBase.closeResources(inputSub); | |
273 | + } | |
274 | + } | |
266 | 275 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EventoRecebimentoObjetoServiceImpl.java
... | ... | @@ -257,10 +257,28 @@ public class EventoRecebimentoObjetoServiceImpl extends GenericServiceImpl<Event |
257 | 257 | try { |
258 | 258 | conn = this.reportService.getConnection(); |
259 | 259 | Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); |
260 | + String titulo = this.internacionalizacaoService.getTranslate("LABEL.TITULO_DOCUMENTO_RECEBIMENTO", this.getIdioma()); | |
261 | + | |
262 | + // Responsavel por verificar a presenca de dados no relatorio | |
263 | + reportService.gerarRelatorio(download, "pdf", this.getJasperPrintRecebimentoObjeto(idRecebimentoObjeto, conn, usuarioLogado, titulo), response, baos, titulo); | |
264 | + | |
265 | + } catch (JRException jre) { | |
266 | + LOG.info("N\u00e3o consegui gerar o relat\u00f3rio de recebimento de objetos. Veja a exce\u00e7\u00e3o para identificar a causa", jre.getCause()); | |
267 | + throw new RuntimeException(jre); | |
268 | + } catch (Exception e) { | |
269 | + throw new BusinessException(); | |
270 | + } finally { | |
271 | + UtilDataBase.closeResources(conn, input, inputSub, baos); | |
272 | + } | |
273 | + } | |
260 | 274 | |
275 | + @Override | |
276 | + public JasperPrint getJasperPrintRecebimentoObjeto(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException { | |
277 | + InputStream inputSub = null; | |
278 | + InputStream input = null; | |
279 | + try { | |
261 | 280 | input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); |
262 | 281 | inputSub = this.getClass().getResourceAsStream("/reports/eventoRecebimentoObjeto.jrxml"); |
263 | - String titulo = this.internacionalizacaoService.getTranslate("LABEL.TITULO_DOCUMENTO_RECEBIMENTO", this.getIdioma()); | |
264 | 282 | |
265 | 283 | JasperDesign jasperDesign = JRXmlLoader.load(input); |
266 | 284 | JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); |
... | ... | @@ -268,7 +286,7 @@ public class EventoRecebimentoObjetoServiceImpl extends GenericServiceImpl<Event |
268 | 286 | JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); |
269 | 287 | |
270 | 288 | Map<String, Object> subReportParameters = new HashMap<String, Object>(); |
271 | - subReportParameters.put("RECEBIMENTO_ID", idRecebimentoObjeto); | |
289 | + subReportParameters.put("RECEBIMENTO_ID", id); | |
272 | 290 | |
273 | 291 | Map<String, Object> parameters = new HashMap<String, Object>(); |
274 | 292 | parameters.put("ORGANIZACAO_ID", usuarioLogado.getOrganizacao().getId()); |
... | ... | @@ -277,18 +295,9 @@ public class EventoRecebimentoObjetoServiceImpl extends GenericServiceImpl<Event |
277 | 295 | parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); |
278 | 296 | parameters.put("REPORT_CONNECTION", conn); |
279 | 297 | |
280 | - JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); | |
281 | - | |
282 | - // Responsavel por verificar a presenca de dados no relatorio | |
283 | - reportService.gerarRelatorio(download, "pdf", jasperPrint, response, baos, titulo); | |
284 | - | |
285 | - } catch (JRException jre) { | |
286 | - LOG.info("N\u00e3o consegui gerar o relat\u00f3rio de recebimento de objetos. Veja a exce\u00e7\u00e3o para identificar a causa", jre.getCause()); | |
287 | - throw new RuntimeException(jre); | |
288 | - } catch (Exception e) { | |
289 | - throw new BusinessException(); | |
290 | - } finally { | |
291 | - UtilDataBase.closeResources(conn, input, inputSub, baos); | |
298 | + return JasperFillManager.fillReport(jasperReport, parameters, conn); | |
299 | + } finally{ | |
300 | + UtilDataBase.closeResources(inputSub); | |
292 | 301 | } |
293 | 302 | } |
294 | 303 | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EventoRepactuacaoServiceImpl.java
1 | 1 | package br.com.centralit.api.service.impl; |
2 | 2 | |
3 | +import java.io.InputStream; | |
4 | +import java.sql.Connection; | |
3 | 5 | import java.text.SimpleDateFormat; |
4 | 6 | import java.util.Collection; |
7 | +import java.util.HashMap; | |
8 | +import java.util.Map; | |
9 | + | |
10 | +import net.sf.jasperreports.engine.JRException; | |
11 | +import net.sf.jasperreports.engine.JasperCompileManager; | |
12 | +import net.sf.jasperreports.engine.JasperFillManager; | |
13 | +import net.sf.jasperreports.engine.JasperPrint; | |
14 | +import net.sf.jasperreports.engine.JasperReport; | |
15 | +import net.sf.jasperreports.engine.design.JasperDesign; | |
16 | +import net.sf.jasperreports.engine.xml.JRXmlLoader; | |
5 | 17 | |
6 | 18 | import org.apache.commons.collections.CollectionUtils; |
7 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -22,11 +34,13 @@ import br.com.centralit.api.service.ParceiroService; |
22 | 34 | import br.com.centralit.api.service.RegistroOcorrenciaService; |
23 | 35 | import br.com.centralit.api.service.UsuarioService; |
24 | 36 | import br.com.centralit.framework.model.Dominio; |
37 | +import br.com.centralit.framework.model.Usuario; | |
25 | 38 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
39 | +import br.com.centralit.framework.util.UtilDataBase; | |
26 | 40 | |
27 | 41 | |
28 | 42 | /** |
29 | - * | |
43 | + * | |
30 | 44 | * <p><img src="http://centralit.com.br/images/logo_central.png"></p> |
31 | 45 | * |
32 | 46 | * <p><b>Company: </b> Central IT - Governança Corporativa - </p> |
... | ... | @@ -34,11 +48,11 @@ import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
34 | 48 | * <p><b>Title: </b></p> |
35 | 49 | * |
36 | 50 | * <p><b>Description: </b></p> |
37 | - * | |
51 | + * | |
38 | 52 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
39 | 53 | * |
40 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
41 | - * | |
54 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
55 | + * | |
42 | 56 | * @since 19/03/2016 - 09:22:20 |
43 | 57 | * |
44 | 58 | * @version 1.0.0 |
... | ... | @@ -63,10 +77,10 @@ public class EventoRepactuacaoServiceImpl extends GenericServiceImpl<EventoRepac |
63 | 77 | |
64 | 78 | @Autowired |
65 | 79 | private ParceiroService parceiroService; |
66 | - | |
80 | + | |
67 | 81 | @Autowired |
68 | 82 | private InternacionalizacaoService internacionalizacaoService; |
69 | - | |
83 | + | |
70 | 84 | @Autowired |
71 | 85 | private RegistroOcorrenciaService registroOcorrenciaService; |
72 | 86 | |
... | ... | @@ -82,14 +96,14 @@ public class EventoRepactuacaoServiceImpl extends GenericServiceImpl<EventoRepac |
82 | 96 | public EventoRepactuacao save(EventoRepactuacao eventoRepactuacao) { |
83 | 97 | |
84 | 98 | montarObjeto(eventoRepactuacao); |
85 | - | |
99 | + | |
86 | 100 | this.validarEntidade(eventoRepactuacao, this.validator); |
87 | 101 | |
88 | 102 | return super.save(eventoRepactuacao); |
89 | 103 | } |
90 | 104 | |
91 | 105 | /** |
92 | - * | |
106 | + * | |
93 | 107 | * @param eventoRepactuacao |
94 | 108 | */ |
95 | 109 | private void montarObjeto(EventoRepactuacao eventoRepactuacao) { |
... | ... | @@ -97,7 +111,7 @@ public class EventoRepactuacaoServiceImpl extends GenericServiceImpl<EventoRepac |
97 | 111 | eventoRepactuacao.setRegistroOcorrencia(this.registroOcorrenciaService.find(eventoRepactuacao.getRegistroOcorrencia().getId())); |
98 | 112 | |
99 | 113 | SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
100 | - | |
114 | + | |
101 | 115 | String descricao = internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EVENTO_REPACTUACAO", this.getIdioma()); |
102 | 116 | descricao = String.format(descricao, eventoRepactuacao.getNumeroRepactuacao(), sdf.format(eventoRepactuacao.getDataRepactuacao().getTime())); |
103 | 117 | eventoRepactuacao.setDescricao(descricao); |
... | ... | @@ -140,4 +154,37 @@ public class EventoRepactuacaoServiceImpl extends GenericServiceImpl<EventoRepac |
140 | 154 | return dominioService.findByChaveAndCodigo("tipoIdioma", Dominio.TIPO_IDIOMA_PT_BR_CODIGO); |
141 | 155 | } |
142 | 156 | |
157 | + @Override | |
158 | + public JasperPrint getJasperPrintRepactuacao(Long id, Connection conn, Usuario user, String titulo) throws JRException { | |
159 | + InputStream inputSub = null; | |
160 | + InputStream input = null; | |
161 | + try { | |
162 | + | |
163 | + input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); | |
164 | + inputSub = this.getClass().getResourceAsStream("/reports/eventoRepactuacao.jrxml"); | |
165 | + | |
166 | + JasperDesign jasperDesign = JRXmlLoader.load(input); | |
167 | + JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); | |
168 | + | |
169 | + JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); | |
170 | + JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); | |
171 | + | |
172 | + Map<String, Object> subReportParameters = new HashMap<String, Object>(); | |
173 | + subReportParameters.put("REPACTUACAO_ID", id); | |
174 | + subReportParameters.put("REPORT_CONNECTION", conn); | |
175 | + | |
176 | + | |
177 | + Map<String, Object> parameters = new HashMap<String, Object>(); | |
178 | + parameters.put("ORGANIZACAO_ID", user.getOrganizacao().getId()); | |
179 | + parameters.put("TITULO", titulo); | |
180 | + parameters.put("SUBREPORT_DIR", jasperReportSub); | |
181 | + parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); | |
182 | + parameters.put("REPORT_CONNECTION", conn); | |
183 | + | |
184 | + return JasperFillManager.fillReport(jasperReport, parameters, conn); | |
185 | + } finally{ | |
186 | + UtilDataBase.closeResources(inputSub); | |
187 | + } | |
188 | + } | |
189 | + | |
143 | 190 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EventoRescisaoContratoServiceImpl.java
... | ... | @@ -196,10 +196,26 @@ public class EventoRescisaoContratoServiceImpl extends GenericServiceImpl<Evento |
196 | 196 | try { |
197 | 197 | conn = reportService.getConnection(); |
198 | 198 | Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); |
199 | + String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_DOCUMENTO_RESCISAO_CONTRATO", this.getIdioma()); | |
200 | + | |
201 | + reportService.gerarRelatorio(download, "pdf", this.getJasperPrintRescisao(idRescisaoContrato, conn, usuarioLogado, titulo), response, baos, titulo); | |
202 | + | |
203 | + } catch (JRException jre) { | |
204 | + throw new RuntimeException(jre); | |
205 | + } catch (Exception e) { | |
206 | + throw new BusinessException(); | |
207 | + } finally { | |
208 | + UtilDataBase.closeResources(conn, input, inputSub, baos); | |
209 | + } | |
210 | + } | |
199 | 211 | |
212 | + @Override | |
213 | + public JasperPrint getJasperPrintRescisao(Long id, Connection conn, Usuario usuarioLogado, String titulo) throws JRException { | |
214 | + InputStream inputSub = null; | |
215 | + InputStream input = null; | |
216 | + try { | |
200 | 217 | input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); |
201 | 218 | inputSub = this.getClass().getResourceAsStream("/reports/eventoRescisaoContrato.jrxml"); |
202 | - String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_DOCUMENTO_RESCISAO_CONTRATO", this.getIdioma()); | |
203 | 219 | |
204 | 220 | JasperDesign jasperDesign = JRXmlLoader.load(input); |
205 | 221 | JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); |
... | ... | @@ -207,7 +223,7 @@ public class EventoRescisaoContratoServiceImpl extends GenericServiceImpl<Evento |
207 | 223 | JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); |
208 | 224 | |
209 | 225 | Map<String, Object> subReportParameters = new HashMap<String, Object>(); |
210 | - subReportParameters.put("RESCISAO_ID", idRescisaoContrato); | |
226 | + subReportParameters.put("RESCISAO_ID", id); | |
211 | 227 | |
212 | 228 | Map<String, Object> parameters = new HashMap<String, Object>(); |
213 | 229 | parameters.put("ORGANIZACAO_ID", usuarioLogado.getOrganizacao().getId()); |
... | ... | @@ -216,16 +232,9 @@ public class EventoRescisaoContratoServiceImpl extends GenericServiceImpl<Evento |
216 | 232 | parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); |
217 | 233 | parameters.put("REPORT_CONNECTION", conn); |
218 | 234 | |
219 | - JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); | |
220 | - | |
221 | - reportService.gerarRelatorio(download, "pdf", jasperPrint, response, baos, titulo); | |
222 | - | |
223 | - } catch (JRException jre) { | |
224 | - throw new RuntimeException(jre); | |
225 | - } catch (Exception e) { | |
226 | - throw new BusinessException(); | |
227 | - } finally { | |
228 | - UtilDataBase.closeResources(conn, input, inputSub, baos); | |
235 | + return JasperFillManager.fillReport(jasperReport, parameters, conn); | |
236 | + } finally{ | |
237 | + UtilDataBase.closeResources(inputSub); | |
229 | 238 | } |
230 | 239 | } |
231 | 240 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/InicializarContratosServiceImpl.java
... | ... | @@ -153,26 +153,8 @@ public class InicializarContratosServiceImpl extends UtilStartup { |
153 | 153 | Menu menuTermosRelatorios = new Menu("Termos e relatórios", null, this.menuContratos, 1, 2, null, null, null, null, modulo, "TERMOS_E_RELATORIOS"); |
154 | 154 | menuTermosRelatorios = this.menuService.mergeIfNotExist(menuTermosRelatorios); |
155 | 155 | |
156 | - // Menu Termo aditivo | |
157 | - criarOpcaoTermoAditivo(modulo, menuTermosRelatorios); | |
158 | - // Menu Termo apostilamento | |
159 | - criarOpcaoTermoApostilamento(modulo, menuTermosRelatorios); | |
160 | - // Menu Termo ciência | |
161 | - criarOpcaoTermoCiencia(modulo, menuTermosRelatorios); | |
162 | - // Menu Termo compromisso | |
163 | - criarOpcaoTermoCompromisso(modulo, menuTermosRelatorios); | |
164 | - // Menu Termo recebimento de objeto | |
165 | - criarOpcaoTermoRecebimentoObjeto(modulo, menuTermosRelatorios); | |
166 | - // Menu Termo recisão contratual | |
167 | - criarOpcaoTermoRescisaoContratual(modulo, menuTermosRelatorios); | |
168 | - // Menu Relatório de ocorrências | |
169 | - criarOpcaoRelatorioOcorrencias(modulo, menuTermosRelatorios); | |
170 | - // Menu Relatório de pagamento | |
171 | - criarOpcaoRelatorioPagamento(modulo, menuTermosRelatorios); | |
172 | - // Menu Relatório de repactuação | |
173 | - criarOpcaoRelatorioRepactuacao(modulo, menuTermosRelatorios); | |
174 | - // Menu Relatório de recisão | |
175 | - criarOpcaoRelatorioRecisao(modulo, menuTermosRelatorios); | |
156 | + criarConsultaTermo(modulo, menuTermosRelatorios); | |
157 | + | |
176 | 158 | } |
177 | 159 | |
178 | 160 | private void criarOpcaoSolicitacaoDemanda(Modulo modulo, Menu menuDemandas) { |
... | ... | @@ -445,13 +427,13 @@ public class InicializarContratosServiceImpl extends UtilStartup { |
445 | 427 | |
446 | 428 | filesMenuAcompanhamento.add(new MenuFile(CIT_CONTRATOS_WEB_ANGULAR_CUSTOM + "controller/EventoEmpenhoController.js", this.dominioJS, menuAcompanhamento)); |
447 | 429 | filesMenuAcompanhamento.add(new MenuFile(CIT_CONTRATOS_WEB_ANGULAR_CUSTOM + "controller/EventoEmpenhoController.min.js", this.dominioJS, menuAcompanhamento)); |
448 | - | |
430 | + | |
449 | 431 | filesMenuAcompanhamento.add(new MenuFile(CIT_CONTRATOS_WEB_ANGULAR_CUSTOM + "controller/EventoRecebimentoObjetoController.js", this.dominioJS, menuAcompanhamento)); |
450 | 432 | filesMenuAcompanhamento.add(new MenuFile(CIT_CONTRATOS_WEB_ANGULAR_CUSTOM + "controller/EventoRecebimentoObjetoController.min.js", this.dominioJS, menuAcompanhamento)); |
451 | 433 | filesMenuAcompanhamento.add(new MenuFile(CIT_CONTRATOS_WEB_ANGULAR_CUSTOM + "repository/EventoRecebimentoObjetoRepository.js", this.dominioJS, menuAcompanhamento)); |
452 | 434 | filesMenuAcompanhamento.add(new MenuFile(CIT_CONTRATOS_WEB_ANGULAR_CUSTOM + "repository/EventoRecebimentoObjetoRepository.min.js", this.dominioJS, menuAcompanhamento)); |
453 | 435 | |
454 | - | |
436 | + | |
455 | 437 | menuAcompanhamento.setIncludes(filesMenuAcompanhamento); |
456 | 438 | |
457 | 439 | this.menuService.mergeIfNotExist(menuAcompanhamento); |
... | ... | @@ -563,92 +545,11 @@ public class InicializarContratosServiceImpl extends UtilStartup { |
563 | 545 | this.menuService.mergeIfNotExist(menuDefinicoesContratos); |
564 | 546 | } |
565 | 547 | |
566 | - private void criarOpcaoTermoAditivo(Modulo modulo, Menu menuTermosRelatorios) { | |
567 | - | |
568 | - Pagina pgTermoAditivo = new Pagina("Termo aditivo", "/cit-contratos-web/html/termoAditivo/termoAditivo.html"); | |
569 | - pgTermoAditivo = this.paginaService.saveIfNotExist(pgTermoAditivo); | |
570 | - Menu menuTermoAditivo = new Menu("Termo aditivo", pgTermoAditivo, menuTermosRelatorios, null, 1, null, null, null, null, modulo, "TERMO_ADITIVO"); | |
571 | - | |
572 | - this.menuService.mergeIfNotExist(menuTermoAditivo); | |
573 | - } | |
574 | - | |
575 | - private void criarOpcaoTermoApostilamento(Modulo modulo, Menu menuTermosRelatorios) { | |
576 | - | |
577 | - Pagina pgTermoApostilamento = new Pagina("Termo de apostilamento", "/cit-contratos-web/html/termoApostilamento/termoApostilamento.html"); | |
578 | - pgTermoApostilamento = this.paginaService.saveIfNotExist(pgTermoApostilamento); | |
579 | - Menu menuTermoApostilamento = new Menu("Termo de apostilamento", pgTermoApostilamento, menuTermosRelatorios, null, 2, null, null, null, null, modulo, "TERMO_APOSTILAMENTO"); | |
580 | - | |
581 | - this.menuService.mergeIfNotExist(menuTermoApostilamento); | |
582 | - } | |
583 | - | |
584 | - private void criarOpcaoTermoCiencia(Modulo modulo, Menu menuTermosRelatorios) { | |
585 | - | |
586 | - Pagina pgTermoCiencia = new Pagina("Termo de ciência", "/cit-contratos-web/html/termoCiencia/termoCiencia.html"); | |
587 | - pgTermoCiencia = this.paginaService.saveIfNotExist(pgTermoCiencia); | |
588 | - Menu menuTermoCiencia = new Menu("Termo de ciênica", pgTermoCiencia, menuTermosRelatorios, null, 3, null, null, null, null, modulo, "TERMO_CIENCIA"); | |
589 | - | |
590 | - this.menuService.mergeIfNotExist(menuTermoCiencia); | |
591 | - } | |
592 | - | |
593 | - private void criarOpcaoTermoCompromisso(Modulo modulo, Menu menuTermosRelatorios) { | |
594 | - | |
595 | - Pagina pgTermoCompromisso = new Pagina("Termo de compromisso", "/cit-contratos-web/html/termoCompromisso/termoCompromisso.html"); | |
596 | - pgTermoCompromisso = this.paginaService.saveIfNotExist(pgTermoCompromisso); | |
597 | - Menu menuTermoCompromisso = new Menu("Termo de compromisso", pgTermoCompromisso, menuTermosRelatorios, null, 4, null, null, null, null, modulo, "TERMO_COMPROMISSO"); | |
598 | - | |
599 | - this.menuService.mergeIfNotExist(menuTermoCompromisso); | |
600 | - } | |
601 | - | |
602 | - private void criarOpcaoTermoRecebimentoObjeto(Modulo modulo, Menu menuTermosRelatorios) { | |
603 | - | |
604 | - Pagina pgTermoRecebimentoObjeto = new Pagina("Termo de recebimento de objeto", "/cit-contratos-web/html/termoRecebimentoObjeto/termoRecebimentoObjeto.html"); | |
605 | - pgTermoRecebimentoObjeto = this.paginaService.saveIfNotExist(pgTermoRecebimentoObjeto); | |
606 | - Menu menuTermoRecebimentoObjeto = new Menu("Termo de recebimento de objeto", pgTermoRecebimentoObjeto, menuTermosRelatorios, null, 5, null, null, null, null, modulo, "TERMO_RECEBIMENTO_OBJETO"); | |
607 | - | |
608 | - this.menuService.mergeIfNotExist(menuTermoRecebimentoObjeto); | |
609 | - } | |
610 | - | |
611 | - private void criarOpcaoTermoRescisaoContratual(Modulo modulo, Menu menuTermosRelatorios) { | |
612 | - | |
613 | - Pagina pgRescisaoContratual = new Pagina("Termo de rescisão contratual", "/cit-contratos-web/html/termoRescisaoContratual/termoRescisaoContratual.html"); | |
614 | - pgRescisaoContratual = this.paginaService.saveIfNotExist(pgRescisaoContratual); | |
615 | - Menu menuTermoRescisaoContratual = new Menu("Termo de rescisão contratual", pgRescisaoContratual, menuTermosRelatorios, null, 6, null, null, null, null, modulo, "TERMO_RESCISAO_CONTRATUAL"); | |
616 | - | |
617 | - this.menuService.mergeIfNotExist(menuTermoRescisaoContratual); | |
618 | - } | |
619 | - | |
620 | - private void criarOpcaoRelatorioOcorrencias(Modulo modulo, Menu menuTermosRelatorios) { | |
621 | - | |
622 | - Pagina pgRelatorioOcorrencias = new Pagina("Relatório de ocorrências", "/cit-contratos-web/html/relatorioOcorrencias/relatorioOcorrencias.html"); | |
623 | - pgRelatorioOcorrencias = this.paginaService.saveIfNotExist(pgRelatorioOcorrencias); | |
624 | - Menu menuRelatorioOcorrencias = new Menu("Relatorio de ocorrências", pgRelatorioOcorrencias, menuTermosRelatorios, null, 7, null, null, null, null, modulo, "RELATORIO_OCORRENCIAS"); | |
625 | - | |
626 | - this.menuService.mergeIfNotExist(menuRelatorioOcorrencias); | |
627 | - } | |
628 | - | |
629 | - private void criarOpcaoRelatorioPagamento(Modulo modulo, Menu menuTermosRelatorios) { | |
630 | - | |
631 | - Pagina pgRelatorioPagamento = new Pagina("Relatório de pagamento", "/cit-contratos-web/html/relatorioPagamento/relatorioPagamento.html"); | |
632 | - pgRelatorioPagamento = this.paginaService.saveIfNotExist(pgRelatorioPagamento); | |
633 | - Menu menuRelatorioPagamento = new Menu("Relatório de pagamento", pgRelatorioPagamento, menuTermosRelatorios, null, 8, null, null, null, null, modulo, "RELATORIO_PAGAMENTO"); | |
634 | - | |
635 | - this.menuService.mergeIfNotExist(menuRelatorioPagamento); | |
636 | - } | |
637 | - | |
638 | - private void criarOpcaoRelatorioRepactuacao(Modulo modulo, Menu menuTermosRelatorios) { | |
639 | - | |
640 | - Pagina pgRelatorioRepactuacao = new Pagina("Relatório de repactuação", "/cit-contratos-web/html/relatorioRepactuacao/relatorioRepactuacao.html"); | |
641 | - pgRelatorioRepactuacao = this.paginaService.saveIfNotExist(pgRelatorioRepactuacao); | |
642 | - Menu menuRelatorioRepactuacao = new Menu("Relatório de repactuação", pgRelatorioRepactuacao, menuTermosRelatorios, null, 9, null, null, null, null, modulo, "RELATORIO_REPACTUACAO"); | |
643 | - | |
644 | - this.menuService.mergeIfNotExist(menuRelatorioRepactuacao); | |
645 | - } | |
646 | - | |
647 | - private void criarOpcaoRelatorioRecisao(Modulo modulo, Menu menuTermosRelatorios) { | |
548 | + private void criarConsultaTermo(Modulo modulo, Menu menuTermosRelatorios) { | |
648 | 549 | |
649 | - Pagina pgRelatorioRecisao = new Pagina("Relatório de recisão", "/cit-contratos-web/html/relatorioRecisao/relatorioRecisao.html"); | |
550 | + Pagina pgRelatorioRecisao = new Pagina("Termos", "/cit-contratos-web/html/consultaTermo/consultaTermo.html"); | |
650 | 551 | pgRelatorioRecisao = this.paginaService.saveIfNotExist(pgRelatorioRecisao); |
651 | - Menu menuRelatorioRecisao = new Menu("Relatório de recisão", pgRelatorioRecisao, menuTermosRelatorios, null, 10, null, null, null, null, modulo, "RELATORIO_RECISAO"); | |
552 | + Menu menuRelatorioRecisao = new Menu("Consulta de Termos", pgRelatorioRecisao, menuTermosRelatorios, null, 1, null, null, null, null, modulo, "CONSULTA_TERMOS"); | |
652 | 553 | |
653 | 554 | this.menuService.mergeIfNotExist(menuRelatorioRecisao); |
654 | 555 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/viewHelper/ContratoEventosVH.java
1 | 1 | package br.com.centralit.api.viewHelper; |
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | +import java.util.ArrayList; | |
4 | 5 | import java.util.Collection; |
5 | 6 | |
6 | 7 | import br.com.centralit.api.model.Contrato; |
7 | 8 | import br.com.centralit.api.model.ContratoEmpenho; |
8 | 9 | import br.com.centralit.api.model.ContratoEvento; |
10 | +import br.com.centralit.framework.model.Dominio; | |
9 | 11 | |
10 | 12 | import com.fasterxml.jackson.annotation.JsonView; |
11 | 13 | |
12 | - | |
13 | 14 | /** |
14 | - * | |
15 | - * <p><img src="http://centralit.com.br/images/logo_central.png"></p> | |
16 | 15 | * |
17 | - * <p><b>Company: </b> Central IT - Governança Corporativa - </p> | |
16 | + * <p> | |
17 | + * <img src="http://centralit.com.br/images/logo_central.png"> | |
18 | + * </p> | |
19 | + * | |
20 | + * <p> | |
21 | + * <b>Company: </b> Central IT - Governança Corporativa - | |
22 | + * </p> | |
23 | + * | |
24 | + * <p> | |
25 | + * <b>Title: </b> | |
26 | + * </p> | |
27 | + * | |
28 | + * <p> | |
29 | + * <b>Description: </b> | |
30 | + * </p> | |
18 | 31 | * |
19 | - * <p><b>Title: </b></p> | |
32 | + * <p> | |
33 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | |
34 | + * </p> | |
20 | 35 | * |
21 | - * <p><b>Description: </b></p> | |
22 | - * | |
23 | - * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> | |
36 | + * <p> | |
37 | + * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | |
38 | + * </p> | |
24 | 39 | * |
25 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
26 | - * | |
27 | 40 | * @since 09/03/2016 - 10:22:53 |
28 | 41 | * |
29 | 42 | * @version 1.0.0 |
... | ... | @@ -35,11 +48,11 @@ public class ContratoEventosVH implements Serializable { |
35 | 48 | |
36 | 49 | /** Atributo serialVersionUID. */ |
37 | 50 | private static final long serialVersionUID = 1317225449654175547L; |
38 | - | |
51 | + | |
39 | 52 | /** Atributo contrato. */ |
40 | 53 | @JsonView({ ViewsContrato.ContratoEventoListView.class }) |
41 | 54 | private Contrato contrato; |
42 | - | |
55 | + | |
43 | 56 | /** Atributo eventos. */ |
44 | 57 | @JsonView({ ViewsContrato.ContratoEventoListView.class }) |
45 | 58 | private Collection<ContratoEvento> eventos; |
... | ... | @@ -47,53 +60,64 @@ public class ContratoEventosVH implements Serializable { |
47 | 60 | /** Atributo empenhos. */ |
48 | 61 | @JsonView({ ViewsContrato.ContratoEventoListView.class }) |
49 | 62 | private Collection<ContratoEmpenho> empenhos; |
50 | - | |
63 | + | |
64 | + @JsonView({ ViewsContrato.ContratoEventoListView.class }) | |
65 | + private Dominio tipoEvento; | |
66 | + | |
51 | 67 | /** |
52 | - * | |
68 | + * | |
53 | 69 | * Responsável pela criação de novas instâncias desta classe. |
70 | + * | |
54 | 71 | * @param contrato |
55 | 72 | * @param eventos |
56 | 73 | * @param totalOcorrencia |
57 | 74 | */ |
58 | - public ContratoEventosVH( Contrato contrato, Collection<ContratoEvento> eventos, Integer totalOcorrencia ) { | |
75 | + public ContratoEventosVH(Contrato contrato, | |
76 | + Collection<ContratoEvento> eventos, Integer totalOcorrencia) { | |
59 | 77 | super(); |
60 | 78 | this.contrato = contrato; |
61 | 79 | this.eventos = eventos; |
62 | 80 | } |
63 | - | |
81 | + | |
64 | 82 | /** |
65 | - * | |
83 | + * | |
66 | 84 | * Responsável pela criação de novas instâncias desta classe. |
85 | + * | |
67 | 86 | * @param contrato |
68 | 87 | * @param eventos |
69 | 88 | */ |
70 | - public ContratoEventosVH( Contrato contrato, Collection<ContratoEvento> eventos, Collection<ContratoEmpenho> empenhos, Integer totalOcorrencia ) { | |
89 | + public ContratoEventosVH(Contrato contrato, | |
90 | + Collection<ContratoEvento> eventos, | |
91 | + Collection<ContratoEmpenho> empenhos, Integer totalOcorrencia) { | |
71 | 92 | super(); |
72 | 93 | this.contrato = contrato; |
73 | 94 | this.eventos = eventos; |
74 | 95 | this.empenhos = empenhos; |
75 | 96 | } |
76 | - | |
97 | + | |
77 | 98 | /** |
78 | - * | |
99 | + * | |
79 | 100 | * Responsável pela criação de novas instâncias desta classe. |
101 | + * | |
80 | 102 | * @param contrato |
81 | 103 | * @param eventos |
82 | 104 | */ |
83 | - public ContratoEventosVH( Contrato contrato, Collection<ContratoEvento> eventos, Collection<ContratoEmpenho> empenhos ) { | |
105 | + public ContratoEventosVH(Contrato contrato, | |
106 | + Collection<ContratoEvento> eventos, | |
107 | + Collection<ContratoEmpenho> empenhos) { | |
84 | 108 | super(); |
85 | 109 | this.contrato = contrato; |
86 | 110 | this.eventos = eventos; |
87 | 111 | this.empenhos = empenhos; |
88 | 112 | } |
89 | - | |
90 | - public ContratoEventosVH(){ | |
113 | + | |
114 | + public ContratoEventosVH() { | |
91 | 115 | super(); |
92 | 116 | } |
93 | 117 | |
94 | 118 | /** |
95 | 119 | * Retorna o valor do atributo <code>contrato</code> |
96 | - * | |
120 | + * | |
97 | 121 | * @return <code>Contrato</code> |
98 | 122 | */ |
99 | 123 | public Contrato getContrato() { |
... | ... | @@ -102,7 +126,7 @@ public class ContratoEventosVH implements Serializable { |
102 | 126 | |
103 | 127 | /** |
104 | 128 | * Define o valor do atributo <code>contrato</code>. |
105 | - * | |
129 | + * | |
106 | 130 | * @param contrato |
107 | 131 | */ |
108 | 132 | public void setContrato(Contrato contrato) { |
... | ... | @@ -111,31 +135,53 @@ public class ContratoEventosVH implements Serializable { |
111 | 135 | |
112 | 136 | /** |
113 | 137 | * Retorna o valor do atributo <code>eventos</code> |
114 | - * | |
138 | + * | |
115 | 139 | * @return <code>Collection<ContratoEvento></code> |
116 | 140 | */ |
117 | - public Collection<ContratoEvento> getOcorrencias() { | |
141 | + public Collection<ContratoEvento> getOcorrencias() { | |
118 | 142 | return eventos; |
119 | 143 | } |
120 | 144 | |
121 | 145 | /** |
122 | 146 | * Define o valor do atributo <code>eventos</code>. |
123 | - * | |
147 | + * | |
124 | 148 | * @param eventos |
125 | 149 | */ |
126 | 150 | public void setOcorrencias(Collection<ContratoEvento> eventos) { |
127 | 151 | this.eventos = eventos; |
128 | 152 | } |
129 | - | |
153 | + | |
130 | 154 | public Collection<ContratoEmpenho> getEmpenhos() { |
131 | - | |
155 | + | |
132 | 156 | return empenhos; |
133 | 157 | } |
134 | 158 | |
135 | - | |
136 | 159 | public void setEmpenhos(Collection<ContratoEmpenho> empenhos) { |
137 | - | |
160 | + | |
138 | 161 | this.empenhos = empenhos; |
139 | 162 | } |
140 | - | |
163 | + | |
164 | + public Collection<ContratoEvento> getEventos() { | |
165 | + return eventos; | |
166 | + } | |
167 | + | |
168 | + public void setEventos(Collection<ContratoEvento> eventos) { | |
169 | + this.eventos = eventos; | |
170 | + } | |
171 | + | |
172 | + public Dominio getTipoEvento() { | |
173 | + return tipoEvento; | |
174 | + } | |
175 | + | |
176 | + public void setTipoEvento(Dominio tipoEvento) { | |
177 | + this.tipoEvento = tipoEvento; | |
178 | + } | |
179 | + | |
180 | + public void addEventos(ContratoEvento evento) { | |
181 | + if(eventos == null){ | |
182 | + eventos = new ArrayList<ContratoEvento>(); | |
183 | + } | |
184 | + eventos.add(evento); | |
185 | + } | |
186 | + | |
141 | 187 | } | ... | ... |
cit-contratos-web/src/main/java/br/com/centralit/controller/ContratoEventoController.java
1 | 1 | package br.com.centralit.controller; |
2 | 2 | |
3 | +import java.io.IOException; | |
4 | +import java.sql.SQLException; | |
5 | +import java.util.ArrayList; | |
6 | +import java.util.Collection; | |
7 | +import java.util.Date; | |
8 | +import java.util.List; | |
9 | + | |
10 | +import javax.servlet.http.HttpServletResponse; | |
11 | + | |
12 | +import net.sf.jasperreports.engine.JRException; | |
13 | + | |
3 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
4 | 15 | import org.springframework.stereotype.Controller; |
5 | 16 | import org.springframework.web.bind.annotation.RequestBody; |
... | ... | @@ -9,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestParam; |
9 | 20 | import org.springframework.web.bind.annotation.ResponseBody; |
10 | 21 | |
11 | 22 | import br.com.centralit.api.model.ContratoEvento; |
23 | +import br.com.centralit.api.model.DominioContrato; | |
12 | 24 | import br.com.centralit.api.service.ContratoEmpenhoService; |
13 | 25 | import br.com.centralit.api.service.ContratoEventoService; |
14 | 26 | import br.com.centralit.api.service.ContratoService; |
... | ... | @@ -16,6 +28,8 @@ import br.com.centralit.api.viewHelper.ContratoEventosVH; |
16 | 28 | import br.com.centralit.api.viewHelper.ViewsContrato; |
17 | 29 | import br.com.centralit.framework.controller.GenericController; |
18 | 30 | import br.com.centralit.framework.json.ResponseBodyWrapper; |
31 | +import br.com.centralit.framework.util.UtilDate; | |
32 | +import br.com.centralit.framework.util.UtilString; | |
19 | 33 | |
20 | 34 | /** |
21 | 35 | * |
... | ... | @@ -113,5 +127,97 @@ public class ContratoEventoController extends GenericController<ContratoEvento> |
113 | 127 | return responseBody; |
114 | 128 | } |
115 | 129 | |
130 | + @RequestMapping(method = RequestMethod.GET, value = "/buscaTermosContrato") | |
131 | + @ResponseBody | |
132 | + public ResponseBodyWrapper buscaTermosContrato( | |
133 | + @RequestParam(value = "contratoId") Long contratoId, | |
134 | + @RequestParam(value = "dataInicial", required = false) String dataInicio, @RequestParam(value = "dataFinal", required = false) String dataFim){ | |
135 | + | |
136 | + List<ContratoEventosVH> lista = new ArrayList<ContratoEventosVH>(); | |
137 | + | |
138 | + Date dataInicial = dataInicio != null ? UtilDate.jsonToDate(dataInicio) : null; | |
139 | + Date dateFinal = dataFim != null ? UtilDate.jsonToDate(dataFim) : null; | |
140 | + | |
141 | + Collection<ContratoEvento> listaEventos = this.contratoEventoService.findAllByContratoIntervalDataEmissao(contratoId, dataInicial, dateFinal); | |
142 | + | |
143 | + ContratoEventosVH contratoEventosVH = new ContratoEventosVH(); | |
144 | + long idAuxDominioEvento = 0; | |
145 | + int countListaEventos = 0; | |
146 | + for (ContratoEvento contratoEvento : listaEventos) { | |
147 | + | |
148 | + //TERMOS PDF NAO IMPLEMENTADOS | |
149 | + if(contratoEvento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_PENALIDADE || contratoEvento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_ATUALIZA_STATUS | |
150 | + || contratoEvento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_LIBERA_PAGAMENTO || contratoEvento.getTipoEvento().getCodigo() == DominioContrato.TIPO_EVENTO_NAO_CONFORMIDADE){ | |
151 | + continue; | |
152 | + } | |
153 | + | |
154 | + countListaEventos ++; | |
155 | + if(idAuxDominioEvento == 0){ | |
156 | + contratoEventosVH.setTipoEvento(contratoEvento.getTipoEvento()); | |
157 | + contratoEventosVH.addEventos(contratoEvento); | |
158 | + idAuxDominioEvento = contratoEvento.getTipoEvento().getId(); | |
159 | + continue; | |
160 | + } | |
161 | + | |
162 | + if(idAuxDominioEvento == contratoEvento.getTipoEvento().getId()){ | |
163 | + contratoEventosVH.addEventos(contratoEvento); | |
164 | + }else{ | |
165 | + lista.add(contratoEventosVH); | |
166 | + contratoEventosVH = new ContratoEventosVH(); | |
167 | + contratoEventosVH.setTipoEvento(contratoEvento.getTipoEvento()); | |
168 | + contratoEventosVH.addEventos(contratoEvento); | |
169 | + idAuxDominioEvento = contratoEvento.getTipoEvento().getId(); | |
170 | + } | |
171 | + | |
172 | + if(countListaEventos == listaEventos.size()){ | |
173 | + lista.add(contratoEventosVH); | |
174 | + } | |
175 | + | |
176 | + } | |
177 | + | |
178 | + if(contratoEventosVH.getEventos() != null && !contratoEventosVH.getEventos().isEmpty()){ | |
179 | + lista.add(contratoEventosVH); | |
180 | + } | |
181 | + | |
182 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(lista, ViewsContrato.ContratoEventoEditView.class); | |
183 | + | |
184 | + return responseBody; | |
185 | + } | |
186 | + | |
187 | + @ResponseBody | |
188 | + @RequestMapping(method = RequestMethod.GET, value = "/pdfGerarTermos") | |
189 | + public void gerarGerarTermos(@RequestParam(value = "idsEventos") String idsEventos,@RequestParam(value = "download") boolean download, HttpServletResponse response) throws SQLException, JRException, IOException { | |
190 | + Long[] arrayLong = getArrayLong(idsEventos); | |
191 | + this.contratoEventoService.gerarTermos(arrayLong, download, response); | |
192 | + } | |
193 | + | |
194 | + private Long[] getArrayLong(String idsEventos) { | |
195 | + Long[] arrayLong = null; | |
196 | + if(!UtilString.isNullOrEmpty(idsEventos)){ | |
197 | + String[] array = idsEventos.split(","); | |
198 | + int leng = array.length; | |
199 | + arrayLong = new Long[leng]; | |
200 | + for (int i = 0; i < leng; i++) { | |
201 | + arrayLong[i] = Long.parseLong(array[i]); | |
202 | + } | |
203 | + } | |
204 | + return arrayLong; | |
205 | + } | |
206 | + | |
207 | + @RequestMapping(method = RequestMethod.GET, value = "/listaIdEventosTermo") | |
208 | + @ResponseBody | |
209 | + public ResponseBodyWrapper listaIdEventosTermo( @RequestParam(value = "termos") String termos, @RequestParam(value = "dataInicial", required = false) String dataInicio, @RequestParam(value = "dataFinal", required = false) String dataFim){ | |
210 | + | |
211 | + Long[] codigosTermo = getArrayLong(termos); | |
212 | + Date dataInicial = dataInicio != null ? UtilDate.jsonToDate(dataInicio) : null; | |
213 | + Date dateFinal = dataFim != null ? UtilDate.jsonToDate(dataFim) : null; | |
214 | + List<Long> idsEventos = new ArrayList<Long>(); | |
215 | + Collection<ContratoEvento> eventos = this.contratoEventoService.findAllByContratoTipoTermoDataEmissao(codigosTermo, dataInicial, dateFinal); | |
216 | + for (ContratoEvento contratoEvento : eventos) { | |
217 | + idsEventos.add(contratoEvento.getId()); | |
218 | + } | |
219 | + return new ResponseBodyWrapper(idsEventos, ViewsContrato.ContratoEventoEditView.class); | |
220 | + | |
221 | + } | |
116 | 222 | |
117 | 223 | } | ... | ... |
cit-contratos-web/src/main/java/br/com/centralit/controller/EventoAditivoController.java
... | ... | @@ -6,19 +6,12 @@ import java.io.InputStream; |
6 | 6 | import java.sql.Connection; |
7 | 7 | import java.sql.SQLException; |
8 | 8 | import java.util.Collection; |
9 | -import java.util.HashMap; | |
10 | -import java.util.Map; | |
11 | 9 | |
12 | 10 | import javax.servlet.http.HttpServletRequest; |
13 | 11 | import javax.servlet.http.HttpServletResponse; |
14 | 12 | |
15 | 13 | import net.sf.jasperreports.engine.JRException; |
16 | -import net.sf.jasperreports.engine.JasperCompileManager; | |
17 | -import net.sf.jasperreports.engine.JasperFillManager; | |
18 | 14 | import net.sf.jasperreports.engine.JasperPrint; |
19 | -import net.sf.jasperreports.engine.JasperReport; | |
20 | -import net.sf.jasperreports.engine.design.JasperDesign; | |
21 | -import net.sf.jasperreports.engine.xml.JRXmlLoader; | |
22 | 15 | |
23 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
24 | 17 | import org.springframework.security.core.context.SecurityContextHolder; |
... | ... | @@ -44,7 +37,7 @@ import br.com.centralit.framework.util.UtilDataBase; |
44 | 37 | |
45 | 38 | |
46 | 39 | /** |
47 | - * | |
40 | + * | |
48 | 41 | * <p><img src="http://centralit.com.br/images/logo_central.png"></p> |
49 | 42 | * |
50 | 43 | * <p><b>Company: </b> Central IT - Governança Corporativa - </p> |
... | ... | @@ -52,11 +45,11 @@ import br.com.centralit.framework.util.UtilDataBase; |
52 | 45 | * <p><b>Title: </b></p> |
53 | 46 | * |
54 | 47 | * <p><b>Description: </b></p> |
55 | - * | |
48 | + * | |
56 | 49 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
57 | 50 | * |
58 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
59 | - * | |
51 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
52 | + * | |
60 | 53 | * @since 15/03/2016 - 18:30:22 |
61 | 54 | * |
62 | 55 | * @version 1.0.0 |
... | ... | @@ -69,13 +62,13 @@ import br.com.centralit.framework.util.UtilDataBase; |
69 | 62 | public class EventoAditivoController extends GenericController<EventoAditivo>{ |
70 | 63 | |
71 | 64 | private EventoAditivoService eventoAditivoService; |
72 | - | |
65 | + | |
73 | 66 | @Autowired |
74 | 67 | private DominioService dominioService; |
75 | - | |
68 | + | |
76 | 69 | @Autowired |
77 | 70 | private InternacionalizacaoService internacionalizacaoService; |
78 | - | |
71 | + | |
79 | 72 | @Autowired |
80 | 73 | private ReportController reportController; |
81 | 74 | |
... | ... | @@ -96,7 +89,7 @@ public class EventoAditivoController extends GenericController<EventoAditivo>{ |
96 | 89 | public Class<ViewsContrato.EventoAditivoEditView> getEditView() { |
97 | 90 | return ViewsContrato.EventoAditivoEditView.class; |
98 | 91 | } |
99 | - | |
92 | + | |
100 | 93 | @RequestMapping(value = "/findAllByContrato", method = RequestMethod.POST) |
101 | 94 | @ResponseBody |
102 | 95 | public ResponseBodyWrapper findAllByContrato(@RequestBody Long contratoId) { |
... | ... | @@ -107,7 +100,7 @@ public class EventoAditivoController extends GenericController<EventoAditivo>{ |
107 | 100 | |
108 | 101 | return responseBody; |
109 | 102 | } |
110 | - | |
103 | + | |
111 | 104 | @RequestMapping(method = RequestMethod.GET, value = "/gerarAditivo") |
112 | 105 | @ResponseBody |
113 | 106 | public void generatePdfRMB(@RequestParam(value="idAditivo") Long idAditivo, @RequestParam(value="download") boolean download, HttpServletResponse response, |
... | ... | @@ -119,33 +112,10 @@ public class EventoAditivoController extends GenericController<EventoAditivo>{ |
119 | 112 | |
120 | 113 | Connection conn = null; |
121 | 114 | ByteArrayOutputStream baos = null; |
122 | - InputStream input = null; | |
123 | - InputStream inputSub = null; | |
124 | 115 | try { |
125 | 116 | conn = reportController.getConnection(); |
126 | - input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); | |
127 | - inputSub = this.getClass().getResourceAsStream("/reports/eventoAditivo.jrxml"); | |
128 | - | |
129 | - JasperDesign jasperDesign = JRXmlLoader.load(input); | |
130 | - JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); | |
131 | - | |
132 | - JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); | |
133 | - JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); | |
134 | - | |
135 | - Map<String, Object> subReportParameters = new HashMap<String, Object>(); | |
136 | - subReportParameters.put("ADITIVO_ID", idAditivo); | |
137 | - subReportParameters.put("REPORT_CONNECTION", conn); | |
138 | - | |
139 | 117 | String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_RELATORIO_ADITIVO", idioma); |
140 | - | |
141 | - Map<String, Object> parameters = new HashMap<String, Object>(); | |
142 | - parameters.put("ORGANIZACAO_ID", user.getOrganizacao().getId()); | |
143 | - parameters.put("TITULO", titulo); | |
144 | - parameters.put("SUBREPORT_DIR", jasperReportSub); | |
145 | - parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); | |
146 | - parameters.put("REPORT_CONNECTION", conn); | |
147 | - | |
148 | - JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); | |
118 | + JasperPrint jasperPrint = this.eventoAditivoService.getJasperPrintAditivo(idAditivo, conn, user, titulo); | |
149 | 119 | |
150 | 120 | // Responsavel por verificar a presenca de dados no relatorio |
151 | 121 | reportController.gerarRelatorio(download, "pdf", jasperPrint, response, baos, titulo); |
... | ... | @@ -155,7 +125,7 @@ public class EventoAditivoController extends GenericController<EventoAditivo>{ |
155 | 125 | } catch (Exception e) { |
156 | 126 | throw new BusinessException(); |
157 | 127 | }finally { |
158 | - UtilDataBase.closeResources(conn, input, inputSub, baos); | |
128 | + UtilDataBase.closeResources(conn, baos); | |
159 | 129 | } |
160 | 130 | |
161 | 131 | } | ... | ... |
cit-contratos-web/src/main/java/br/com/centralit/controller/EventoRepactuacaoController.java
... | ... | @@ -5,19 +5,11 @@ import java.io.IOException; |
5 | 5 | import java.io.InputStream; |
6 | 6 | import java.sql.Connection; |
7 | 7 | import java.sql.SQLException; |
8 | -import java.util.HashMap; | |
9 | -import java.util.Map; | |
10 | 8 | |
11 | 9 | import javax.servlet.http.HttpServletRequest; |
12 | 10 | import javax.servlet.http.HttpServletResponse; |
13 | 11 | |
14 | 12 | import net.sf.jasperreports.engine.JRException; |
15 | -import net.sf.jasperreports.engine.JasperCompileManager; | |
16 | -import net.sf.jasperreports.engine.JasperFillManager; | |
17 | -import net.sf.jasperreports.engine.JasperPrint; | |
18 | -import net.sf.jasperreports.engine.JasperReport; | |
19 | -import net.sf.jasperreports.engine.design.JasperDesign; | |
20 | -import net.sf.jasperreports.engine.xml.JRXmlLoader; | |
21 | 13 | |
22 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
23 | 15 | import org.springframework.security.core.context.SecurityContextHolder; |
... | ... | @@ -41,7 +33,7 @@ import br.com.centralit.framework.util.UtilDataBase; |
41 | 33 | |
42 | 34 | |
43 | 35 | /** |
44 | - * | |
36 | + * | |
45 | 37 | * <p><img src="http://centralit.com.br/images/logo_central.png"></p> |
46 | 38 | * |
47 | 39 | * <p><b>Company: </b> Central IT - Governança Corporativa - </p> |
... | ... | @@ -49,11 +41,11 @@ import br.com.centralit.framework.util.UtilDataBase; |
49 | 41 | * <p><b>Title: </b></p> |
50 | 42 | * |
51 | 43 | * <p><b>Description: </b></p> |
52 | - * | |
44 | + * | |
53 | 45 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
54 | 46 | * |
55 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
56 | - * | |
47 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
48 | + * | |
57 | 49 | * @since 19/03/2016 - 09:44:20 |
58 | 50 | * |
59 | 51 | * @version 1.0.0 |
... | ... | @@ -66,16 +58,16 @@ import br.com.centralit.framework.util.UtilDataBase; |
66 | 58 | public class EventoRepactuacaoController extends GenericController<EventoRepactuacao> { |
67 | 59 | |
68 | 60 | private EventoRepactuacaoService eventoRepactuacaoService; |
69 | - | |
61 | + | |
70 | 62 | @Autowired |
71 | 63 | private DominioService dominioService; |
72 | - | |
64 | + | |
73 | 65 | @Autowired |
74 | 66 | private InternacionalizacaoService internacionalizacaoService; |
75 | - | |
67 | + | |
76 | 68 | @Autowired |
77 | 69 | private ReportController reportController; |
78 | - | |
70 | + | |
79 | 71 | public EventoRepactuacaoController() { |
80 | 72 | super(); |
81 | 73 | } |
... | ... | @@ -95,7 +87,7 @@ public class EventoRepactuacaoController extends GenericController<EventoRepactu |
95 | 87 | super(eventoRepactuacaoService); |
96 | 88 | this.eventoRepactuacaoService = (EventoRepactuacaoService) eventoRepactuacaoService; |
97 | 89 | } |
98 | - | |
90 | + | |
99 | 91 | @RequestMapping(method = RequestMethod.GET, value = "/gerarRepactuacao") |
100 | 92 | @ResponseBody |
101 | 93 | public void generatePdfRMB(@RequestParam(value="idRepactuacao") Long idRepactuacao, @RequestParam(value="download") boolean download, HttpServletResponse response, |
... | ... | @@ -111,32 +103,10 @@ public class EventoRepactuacaoController extends GenericController<EventoRepactu |
111 | 103 | InputStream inputSub = null; |
112 | 104 | try { |
113 | 105 | conn = reportController.getConnection(); |
114 | - input = this.getClass().getResourceAsStream("/reports/templateRetrato.jrxml"); | |
115 | - inputSub = this.getClass().getResourceAsStream("/reports/eventoRepactuacao.jrxml"); | |
116 | - | |
117 | - JasperDesign jasperDesign = JRXmlLoader.load(input); | |
118 | - JasperDesign jasperDesignSub = JRXmlLoader.load(inputSub); | |
119 | - | |
120 | - JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); | |
121 | - JasperReport jasperReportSub = JasperCompileManager.compileReport(jasperDesignSub); | |
122 | - | |
123 | - Map<String, Object> subReportParameters = new HashMap<String, Object>(); | |
124 | - subReportParameters.put("REPACTUACAO_ID", idRepactuacao); | |
125 | - subReportParameters.put("REPORT_CONNECTION", conn); | |
126 | - | |
127 | 106 | String titulo = this.internacionalizacaoService.getTranslate("CONTRATOS.LABEL.TITULO_RELATORIO_REPACTUACAO", idioma); |
128 | 107 | |
129 | - Map<String, Object> parameters = new HashMap<String, Object>(); | |
130 | - parameters.put("ORGANIZACAO_ID", user.getOrganizacao().getId()); | |
131 | - parameters.put("TITULO", titulo); | |
132 | - parameters.put("SUBREPORT_DIR", jasperReportSub); | |
133 | - parameters.put("SUBREPORT_PARAMETERS_MAP", subReportParameters); | |
134 | - parameters.put("REPORT_CONNECTION", conn); | |
135 | - | |
136 | - JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); | |
137 | - | |
138 | 108 | // Responsavel por verificar a presenca de dados no relatorio |
139 | - reportController.gerarRelatorio(download, "pdf", jasperPrint, response, baos, titulo); | |
109 | + reportController.gerarRelatorio(download, "pdf", this.eventoRepactuacaoService.getJasperPrintRepactuacao(idRepactuacao, conn, user, titulo), response, baos, titulo); | |
140 | 110 | |
141 | 111 | } catch (JRException jre) { |
142 | 112 | throw new RuntimeException(jre); | ... | ... |
cit-contratos-web/src/main/java/br/com/centralit/listener/StartupListenerContratos.java
... | ... | @@ -979,6 +979,15 @@ public class StartupListenerContratos extends UtilStartup implements Application |
979 | 979 | internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.TITULO_DOCUMENTO_EMPENHO", "Registro de Nota de Empenho", dominio, modulo)); |
980 | 980 | internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.GERAR_REGISTRO_EMPENHO", "Gerar registro de nota de empenho", dominio, modulo)); |
981 | 981 | |
982 | + internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.GERAR", "Gerar", dominio, modulo)); | |
983 | + internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.EMITIR_CONSULTA_TERMOS", "Emitir consulta de termos", dominio, modulo)); | |
984 | + internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.NAO_HA_TERMOS", "Não há termos para este contrato", dominio, modulo)); | |
985 | + internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.DATA_INICIAL", "Data inicial", dominio, modulo)); | |
986 | + internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.DATA_FINAL", "Data final", dominio, modulo)); | |
987 | + internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.TIPO_TERMO", "Tipo de termo", dominio, modulo)); | |
988 | + internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.TERMOS", "Termos do contrato", dominio, modulo)); | |
989 | + internacionalizacaoList.add(new Internacionalizacao("CONTRATOS.LABEL.SELECIONE", "Selecione os tipos do termo que deseja gerar", dominio, modulo)); | |
990 | + | |
982 | 991 | } |
983 | 992 | |
984 | 993 | private void gerarMensagem(Dominio dominio, Modulo modulo, List<Internacionalizacao> internacionalizacaoList) { | ... | ... |
cit-contratos-web/src/main/webapp/assets/js/angular/custom/controller/TermoEventoContratoController.js
1 | 1 | 'use strict'; |
2 | 2 | |
3 | 3 | citApp.controller('TermoEventoContratoController', ['$scope', |
4 | - '$translate', | |
5 | - '$timeout', | |
6 | - 'ContratoEventoRepository', | |
7 | - 'ContratoRepository', | |
8 | - function TermoEventoContratoController($scope, | |
9 | - $translate, | |
10 | - $timeout, | |
11 | - ContratoEventoRepository, | |
12 | - ContratoRepository) { | |
13 | - | |
14 | - $scope.evento = null; | |
15 | - $scope.contrato = null; | |
16 | - $scope.listaEvento = []; | |
17 | - | |
18 | - $scope.findContrato = function (value) { | |
19 | - return ContratoRepository.findContrato(value, $scope.usuarioLogado.organizacao.id).then(function (result) { | |
20 | - return result; | |
21 | - }); | |
22 | - }; | |
23 | - | |
24 | - $scope.buscarEventos = function (contrato, tipoEventoNome) { | |
25 | - $scope.contratoEventos = []; | |
26 | - $scope.setLoadingGet(true); | |
27 | - $timeout(function () { | |
28 | - | |
29 | - ContratoEventoRepository.buscaEventosContratoPorTipo(contrato.id, tipoEventoNome).then(function (result) { | |
30 | - $scope.setLoading(false); | |
31 | - var eventos = result; | |
32 | - $scope.listaEvento = []; | |
33 | - if(eventos){ | |
34 | - angular.forEach(eventos, function(evento, key) { | |
35 | - $scope.listaEvento.push(evento.id); | |
36 | - }); | |
37 | - } | |
38 | - $scope.setLoadingGet(false); | |
39 | - }); | |
40 | - }, 1000); | |
41 | - }; | |
42 | - | |
43 | - $scope.resetForm = function () { | |
44 | - $scope.contrato = null; | |
45 | - $scope.evento = null; | |
46 | - }; | |
47 | - | |
48 | - //########## RESCISAO CONTRATUAL ############## | |
49 | - | |
50 | - $scope.filterCriteriaRescisao = { | |
51 | - start : 1, | |
52 | - dir : 'asc', | |
53 | - sort : 'dataRescisao', | |
54 | - limit : 10, | |
55 | - }; | |
56 | - | |
57 | - $scope.fieldsRescisao = [ 'id', 'numeroRescisao', 'dataRescisao']; | |
58 | - | |
59 | - $scope.headersRescisao = [{ | |
60 | - title : $translate.instant('CONTRATOS.RESCISAO_CONTRATO.NUM_RESCISAO'), | |
61 | - value : 'numeroRescisao', | |
62 | - align : 'left' | |
63 | - },{ | |
64 | - title : $translate.instant('CONTRATOS.RESCISAO_CONTRATO.DATA_RESCISAO'), | |
65 | - value : 'dataRescisao', | |
66 | - date : true | |
67 | - }]; | |
68 | - | |
69 | - $scope.filtersRescisao = [{ | |
70 | - type : 'string', | |
71 | - field : 'numeroRescisao' | |
72 | - },{ | |
73 | - type : 'date-range', | |
74 | - field : 'dataRescisao', | |
75 | - }]; | |
76 | - | |
77 | - $scope.gerarTermoRescisaoContrato = function(){ | |
78 | - $scope.url = '/cit-contratos-web/rest/eventoRescisaoContrato/pdfGerarTermoRescisaoContrato?idRescisaoContrato=' + $scope.evento.id; | |
79 | - $scope.visualizarRelatorio($scope.url, $translate.instant('CONTRATOS.LABEL.TITULO_DOCUMENTO_RESCISAO_CONTRATO')); | |
80 | - }; | |
81 | - | |
82 | - //########## REPACTUACAO CONTRATUAL ############## | |
83 | - | |
84 | - $scope.filterCriteriaRepactuacao = { | |
85 | - start : 1, | |
86 | - dir : 'asc', | |
87 | - sort : 'dataRepactuacao', | |
88 | - limit : 10, | |
89 | - }; | |
90 | - | |
91 | - $scope.fieldsRepactuacao = [ 'id', 'numeroRepactuacao', 'dataRepactuacao']; | |
92 | - | |
93 | - $scope.headersRepactuacao = [{ | |
94 | - title : $translate.instant('CONTRATOS.LABEL.NUM_REPACTUACAO'), | |
95 | - value : 'numeroRepactuacao', | |
96 | - align : 'left' | |
97 | - },{ | |
98 | - title : $translate.instant('CONTRATOS.LABEL.DATA_REPACTUACAO'), | |
99 | - value : 'dataRepactuacao', | |
100 | - date : true | |
101 | - }]; | |
102 | - | |
103 | - $scope.filtersRepactuacao = [{ | |
104 | - type : 'string', | |
105 | - field : 'numeroRepactuacao' | |
106 | - },{ | |
107 | - type : 'date-range', | |
108 | - field : 'dataRepactuacao', | |
109 | - }]; | |
110 | - | |
111 | - $scope.gerarTermoRepactuacao = function(){ | |
112 | - $scope.url = '/cit-contratos-web/rest/eventoRepactuacao/gerarRepactuacao?idRepactuacao=' + $scope.evento.id; | |
113 | - $scope.visualizarRelatorio($scope.url, $translate.instant('CONTRATOS.LABEL.TITULO_RELATORIO_REPACTUACAO')); | |
114 | - }; | |
115 | - | |
116 | -//########## ADITIVO ############## | |
117 | - | |
118 | - $scope.filterCriteriaAditivo = { | |
119 | - start : 1, | |
120 | - dir : 'asc', | |
121 | - sort : 'dataEmissao', | |
122 | - limit : 10, | |
123 | - }; | |
4 | + '$translate', | |
5 | + '$timeout', | |
6 | + 'ContratoEventoRepository', | |
7 | + 'ContratoRepository', | |
8 | + 'DominioRepository', | |
9 | + function TermoEventoContratoController($scope, | |
10 | + $translate, | |
11 | + $timeout, | |
12 | + ContratoEventoRepository, | |
13 | + ContratoRepository, | |
14 | + DominioRepository) { | |
15 | + | |
16 | + $scope.evento = null; | |
17 | + $scope.contrato = null; | |
18 | + $scope.listaEvento = []; | |
19 | + $scope.termos = []; | |
20 | + $scope.termosTemp = []; | |
21 | + $scope.selectedAllTermos = false; | |
22 | + | |
23 | + DominioRepository.findAllDominio('tipoEventoContrato').then(function (result) { | |
24 | + angular.forEach(result, function(dominio, key) { | |
25 | + if(dominio.codigo != 2 && dominio.codigo != 4 && dominio.codigo != 5 && dominio.codigo != 7){ | |
26 | + $scope.termosTemp.push({tipoEvento : { descricao : dominio.descricao, codigo : dominio.codigo}}); | |
27 | + $scope.termos.push({tipoEvento : { descricao : dominio.descricao, codigo : dominio.codigo}}); | |
28 | + } | |
29 | + }); | |
30 | + }); | |
31 | + | |
32 | + $scope.findContrato = function (value) { | |
33 | + return ContratoRepository.findContrato(value, $scope.usuarioLogado.organizacao.id).then(function (result) { | |
34 | + return result; | |
35 | + }); | |
36 | + }; | |
124 | 37 | |
125 | - $scope.fieldsAditivo = [ 'id', 'registroSequencial.sequencialAno', 'dataEmissao']; | |
38 | + $scope.buscarEventos = function (contrato) { | |
39 | + $scope.contratoEventos = []; | |
40 | + if(contrato.id){ | |
41 | + $scope.setLoadingGet(true); | |
42 | + ContratoEventoRepository.buscaTermosContrato(contrato.id, $scope.dataInicio, $scope.dataFim).then(function (result) { | |
43 | + $scope.setLoading(false); | |
44 | + $scope.termos = result; | |
45 | + $scope.setLoadingGet(false); | |
46 | + }); | |
47 | + } | |
48 | + }; | |
126 | 49 | |
127 | - $scope.headersAditivo = [{ | |
128 | - title : $translate.instant('CONTRATOS.LABEL.NUM_ADITIVO'), | |
129 | - value : 'registroSequencial.sequencialAno', | |
130 | - align : 'left', | |
131 | - mask : [new RegExp(/(\d{4})(\d{1,4})/), '$1/$2'] | |
132 | - },{ | |
133 | - title : $translate.instant('LABEL.DATA_EMISSAO'), | |
134 | - value : 'dataEmissao', | |
135 | - date : true | |
136 | - }]; | |
50 | + $scope.resetForm = function () { | |
51 | + $scope.contrato = null; | |
52 | + $scope.selectedAllTermos = false; | |
53 | + $scope.termos = angular.copy($scope.termosTemp); | |
54 | + $timeout(function(){ | |
55 | + $scope.consultaTermoForm.$submitted = true; | |
56 | + $scope.consultaTermoForm.$setPristine(); | |
57 | + }); | |
58 | + }; | |
137 | 59 | |
138 | - $scope.filtersAditivo = [{ | |
139 | - type : 'string', | |
140 | - field : 'registroSequencial.sequencialAno' | |
141 | - },{ | |
142 | - type : 'date-range', | |
143 | - field : 'dataEmissao', | |
144 | - }]; | |
60 | + $scope.buscaEventosData = function(){ | |
61 | + if($scope.contrato){ | |
62 | + $scope.buscarEventos($scope.contrato); | |
63 | + } | |
64 | + }; | |
145 | 65 | |
146 | - $scope.gerarTermoAditivo = function(){ | |
147 | - $scope.url = '/cit-contratos-web/rest/eventoAditivo/gerarAditivo?idAditivo=' + $scope.evento.id; | |
148 | - $scope.visualizarRelatorio($scope.url, $translate.instant('CONTRATOS.LABEL.TITULO_RELATORIO_ADITIVO')); | |
66 | + $scope.gerarTermo = function() { | |
67 | + $scope.consultaTermoForm.$submitted = true; | |
68 | + if($scope.consultaTermoForm.$valid){ | |
69 | + $scope.setLoading(true); | |
70 | + var idsTermosSelecionados = ''; | |
71 | + var codigoTermoChecked = []; | |
72 | + angular.forEach($scope.termos, function(termo) { | |
73 | + if(termo.$checked){ | |
74 | + if(termo.eventos){ | |
75 | + angular.forEach(termo.eventos, function(evento) { | |
76 | + idsTermosSelecionados += evento.id + ','; | |
77 | + }); | |
78 | + } | |
79 | + codigoTermoChecked.push(termo.tipoEvento.codigo); | |
80 | + } | |
81 | + }); | |
82 | + | |
83 | + if(codigoTermoChecked.length == 0){ | |
84 | + $scope.setLoading(false); | |
85 | + $scope.showAlert('warning', $translate.instant('CONTRATOS.LABEL.SELECIONE')); | |
86 | + return; | |
87 | + }else{ | |
88 | + if(codigoTermoChecked.length > 0 && idsTermosSelecionados == ''){ | |
89 | + $scope.setLoading(true); | |
90 | + ContratoEventoRepository.listaIdEventosTermo(codigoTermoChecked, $scope.dataInicio, $scope.dataFim).then(function (result) { | |
91 | + $scope.setLoadingGet(false); | |
92 | + $scope.url = '/cit-contratos-web/rest/contratoEvento/pdfGerarTermos?idsEventos='+ result; | |
93 | + $scope.visualizarRelatorio($scope.url,$translate.instant('CONTRATOS.LABEL.TERMOS')); | |
94 | + }); | |
95 | + }else{ | |
96 | + $scope.setLoadingGet(false); | |
97 | + $scope.url = '/cit-contratos-web/rest/contratoEvento/pdfGerarTermos?idsEventos='+ idsTermosSelecionados; | |
98 | + $scope.visualizarRelatorio($scope.url,$translate.instant('CONTRATOS.LABEL.TERMOS')); | |
99 | + } | |
100 | + } | |
101 | + | |
102 | + } | |
149 | 103 | }; |
150 | 104 | |
151 | 105 | }]); | ... | ... |
cit-contratos-web/src/main/webapp/assets/js/angular/custom/repository/ContratoEventoRepository.js
... | ... | @@ -16,6 +16,14 @@ citApp.factory('ContratoEventoRepository', ['RestangularContratos', 'AbstractRep |
16 | 16 | this.buscaEventosContratoPorTipo = function(contratoId, tipoEvento) { |
17 | 17 | return restangularContratos.one(this.route).getList("buscaEventosContratoPorTipo", {contratoId : contratoId, tipoEvento : tipoEvento}).then(); |
18 | 18 | }; |
19 | + | |
20 | + this.buscaTermosContrato = function(contratoId, dataInicial, dataFinal) { | |
21 | + return restangularContratos.one(this.route+"/buscaTermosContrato").get({"contratoId" : contratoId, "dataInicial": dataInicial, "dataFinal" : dataFinal}).then(); | |
22 | + }; | |
23 | + | |
24 | + this.listaIdEventosTermo = function(termos, dataInicial, dataFinal) { | |
25 | + return restangularContratos.one(this.route+"/listaIdEventosTermo").get({"termos" : termos, "dataInicial": dataInicial, "dataFinal" : dataFinal}).then(); | |
26 | + }; | |
19 | 27 | } |
20 | 28 | |
21 | 29 | AbstractRepository.extend(ContratoEventoRepository); | ... | ... |
cit-contratos-web/src/main/webapp/html/consultaTermo/consultaTermo.html
0 → 100644
... | ... | @@ -0,0 +1,60 @@ |
1 | +<div id="consultaTermo" class="page-content clearfix" ng-controller="TermoEventoContratoController"> | |
2 | + | |
3 | + <div class="bar-buttons-action fixed"> | |
4 | + <div class="row"> | |
5 | + <div class="col-sm-9 text-left"> | |
6 | + <button title="{{$translate.instant('CONTRATOS.LABEL.GERAR')}}" alt="{{$translate.instant('CONTRATOS.LABEL.GERAR')}}" | |
7 | + class="btn btn-clear" type="button" ng-disabled="false" ng-click="gerarTermo();"> | |
8 | + <i class="fa fa-print"></i> | |
9 | + <translate>CONTRATOS.LABEL.GERAR</translate> | |
10 | + </button> | |
11 | + </div><!-- .col --> | |
12 | + | |
13 | + <div class="col-sm-3 text-right"> | |
14 | + <favorito/> | |
15 | + <help-button workspace="workspace" /> | |
16 | + </div><!-- .col --> | |
17 | + </div><!-- .row --> | |
18 | + </div><!-- .bar-buttons-action --> | |
19 | + | |
20 | + <breadcrumb ng-workspace="workspace"></breadcrumb> | |
21 | + <form name="consultaTermoForm"> | |
22 | + <legend><translate>CONTRATOS.LABEL.EMITIR_CONSULTA_TERMOS</translate></legend> | |
23 | + | |
24 | + <div class="row"> | |
25 | + <div class="col-sm-4"> | |
26 | + <auto-complete ng-label="CONTRATOS.LABEL.SELECIONE_CONTRATO" ng-find="findContrato(value)" ng-item="item.numeroAnoContratoFormatado" ng-id="contrato" ng-acao-borracha="resetForm()" | |
27 | + ng-model="contrato" form="consultaTermoForm" ng-obrigatorio="false" ng-set-result="buscarEventos(item)"> | |
28 | + </auto-complete> | |
29 | + </div> | |
30 | + <div class="col-sm-4"> | |
31 | + <label-input-data ng-id="dataInicio" ng-label="CONTRATOS.LABEL.DATA_INICIAL" ng-model="dataInicio" form="consultaTermoForm" ng-obrigatorio="!contrato" ng-custom-change="buscaEventosData()"/> | |
32 | + </div> | |
33 | + <div class="col-sm-4"> | |
34 | + <label-input-data ng-id="dataFim" ng-label="CONTRATOS.LABEL.DATA_FINAL" ng-model="dataFim" form="consultaTermoForm" ng-obrigatorio="!contrato" ng-custom-change="buscaEventosData()"/> | |
35 | + </div> | |
36 | + </div> | |
37 | + <div class="row"> | |
38 | + <div class="col-sm-12"> | |
39 | + <table class="table table-bordered table-striped"> | |
40 | + <thead> | |
41 | + <tr> | |
42 | + <th style="width: 5%;" class="text-center"> | |
43 | +<!-- <input type="checkbox" ng-model="selectedAllTermos" ng-checked="selectedAllTermos" ng-click="selectedAllTermos(selectedAllTermos);" /> --> | |
44 | + </th> | |
45 | + <th><translate>CONTRATOS.LABEL.TIPO_TERMO</translate></th> | |
46 | + </tr> | |
47 | + </thead> | |
48 | + <tbody> | |
49 | + <tr <tr ng-hide="(termos && termos.length != 0)"> | |
50 | + <td colspan="5" class="text-center"><translate>CONTRATOS.LABEL.NAO_HA_TERMOS</translate></td> | |
51 | + </tr> | |
52 | + <tr ng-repeat="termo in termos"> | |
53 | + <td class="text-center"><input type="checkbox" ng-model="termo.$checked" ng-checked="termo.$checked"/></td> | |
54 | + <td class="text-left">{{ termo.tipoEvento.descricao }}</td> | |
55 | + </tr> | |
56 | + </tbody> | |
57 | + </table> | |
58 | + </div> | |
59 | + </form> | |
60 | +</div> | ... | ... |