Commit ff38e281cc960f27b1c2f71e7c7c880634b5ad17
1 parent
46666e8c
Exists in
master
[Redmine Atendimento #4206]Evento rescisão / repactuação
Showing
7 changed files
with
112 additions
and
12 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EventoRepactuacaoServiceImpl.java
... | ... | @@ -16,8 +16,10 @@ import net.sf.jasperreports.engine.design.JasperDesign; |
16 | 16 | import net.sf.jasperreports.engine.xml.JRXmlLoader; |
17 | 17 | |
18 | 18 | import org.apache.commons.collections.CollectionUtils; |
19 | +import org.apache.commons.lang.StringUtils; | |
19 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
20 | 21 | import org.springframework.beans.factory.annotation.Qualifier; |
22 | +import org.springframework.security.core.context.SecurityContextHolder; | |
21 | 23 | import org.springframework.stereotype.Service; |
22 | 24 | import org.springframework.validation.Validator; |
23 | 25 | |
... | ... | @@ -37,6 +39,8 @@ import br.com.centralit.framework.model.Dominio; |
37 | 39 | import br.com.centralit.framework.model.Usuario; |
38 | 40 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
39 | 41 | import br.com.centralit.framework.util.UtilDataBase; |
42 | +import br.com.centralit.framework.util.UtilDate; | |
43 | +import br.com.centralit.framework.util.UtilObjeto; | |
40 | 44 | |
41 | 45 | |
42 | 46 | /** |
... | ... | @@ -95,8 +99,8 @@ public class EventoRepactuacaoServiceImpl extends GenericServiceImpl<EventoRepac |
95 | 99 | @Override |
96 | 100 | public EventoRepactuacao save(EventoRepactuacao eventoRepactuacao) { |
97 | 101 | |
102 | + configurarCodigo(eventoRepactuacao); | |
98 | 103 | montarObjeto(eventoRepactuacao); |
99 | - | |
100 | 104 | this.validarEntidade(eventoRepactuacao, this.validator); |
101 | 105 | |
102 | 106 | return super.save(eventoRepactuacao); |
... | ... | @@ -111,9 +115,11 @@ public class EventoRepactuacaoServiceImpl extends GenericServiceImpl<EventoRepac |
111 | 115 | eventoRepactuacao.setRegistroOcorrencia(this.registroOcorrenciaService.find(eventoRepactuacao.getRegistroOcorrencia().getId())); |
112 | 116 | |
113 | 117 | SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
118 | + String ano = UtilDate.getAnoAtual(); | |
119 | + String[] numeroMask = eventoRepactuacao.getNumeroRepactuacao().split(ano); | |
114 | 120 | |
115 | 121 | String descricao = internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EVENTO_REPACTUACAO", this.getIdioma()); |
116 | - descricao = String.format(descricao, eventoRepactuacao.getNumeroRepactuacao(), sdf.format(eventoRepactuacao.getDataRepactuacao().getTime())); | |
122 | + descricao = String.format(descricao, numeroMask.length > 0 ? numeroMask[0] + "/" + ano : eventoRepactuacao.getNumeroRepactuacao(), sdf.format(eventoRepactuacao.getDataRepactuacao().getTime())); | |
117 | 123 | eventoRepactuacao.setDescricao(descricao); |
118 | 124 | eventoRepactuacao.setContrato(this.contratoService.getReference(eventoRepactuacao.getContrato().getId())); |
119 | 125 | eventoRepactuacao.setDataEvento(eventoRepactuacao.getDataRepactuacao()); |
... | ... | @@ -187,4 +193,19 @@ public class EventoRepactuacaoServiceImpl extends GenericServiceImpl<EventoRepac |
187 | 193 | } |
188 | 194 | } |
189 | 195 | |
196 | + private void configurarCodigo(EventoRepactuacao entitySaved) { | |
197 | + Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); | |
198 | + String ano = UtilDate.getAnoAtual(); | |
199 | + EventoRepactuacao ultimoRegistro = (EventoRepactuacao) this.eventoRepactuacaoDao.buscarUltimoAnoRegistroComOrdenadoParametrizada("numeroRepactuacao", ano, usuarioLogado.getOrganizacao().getId()); | |
200 | + Long sequencial = null; | |
201 | + | |
202 | + if (UtilObjeto.isReferencia(ultimoRegistro)) { | |
203 | + sequencial = ultimoRegistro.getNumeroRepactuacao().replace(ano, "") == null ? null : Long.parseLong(ultimoRegistro.getNumeroRepactuacao().replace(ano, "") ); | |
204 | + }else{ | |
205 | + sequencial = 0l; | |
206 | + } | |
207 | + | |
208 | + entitySaved.setNumeroRepactuacao(StringUtils.leftPad((Long.valueOf(sequencial + 1)).toString(), 5, "0") + ano); | |
209 | + } | |
210 | + | |
190 | 211 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EventoRescisaoContratoServiceImpl.java
... | ... | @@ -20,6 +20,7 @@ import net.sf.jasperreports.engine.JasperReport; |
20 | 20 | import net.sf.jasperreports.engine.design.JasperDesign; |
21 | 21 | import net.sf.jasperreports.engine.xml.JRXmlLoader; |
22 | 22 | |
23 | +import org.apache.commons.lang.StringUtils; | |
23 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
24 | 25 | import org.springframework.beans.factory.annotation.Qualifier; |
25 | 26 | import org.springframework.security.core.context.SecurityContextHolder; |
... | ... | @@ -48,6 +49,7 @@ import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
48 | 49 | import br.com.centralit.framework.util.Util; |
49 | 50 | import br.com.centralit.framework.util.UtilColecao; |
50 | 51 | import br.com.centralit.framework.util.UtilDataBase; |
52 | +import br.com.centralit.framework.util.UtilDate; | |
51 | 53 | import br.com.centralit.framework.util.UtilObjeto; |
52 | 54 | |
53 | 55 | /** |
... | ... | @@ -110,18 +112,21 @@ public class EventoRescisaoContratoServiceImpl extends GenericServiceImpl<Evento |
110 | 112 | |
111 | 113 | Contrato contrato = this.contratoService.find(entity.getContrato().getId()); |
112 | 114 | entity.setContrato(contrato); |
115 | + configurarCodigo(entity); | |
113 | 116 | this.validarEntidade(entity, this.validator); |
114 | 117 | alteraStatusContratoParaRescindido(contrato); |
115 | 118 | entity.setDataEvento(entity.getDataRescisao()); |
116 | 119 | String descricao = ""; |
117 | 120 | SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); |
118 | 121 | String date = sdf.format(new Date()); |
122 | + String ano = UtilDate.getAnoAtual(); | |
123 | + String[] numeroMask = entity.getNumeroRescisao().split(ano); | |
119 | 124 | if(entity.getDevolucaoValor()){ |
120 | 125 | descricao = this.internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EVENTO_RESCISAO_CONTRATO_COM_DEVOLUCAO_VALOR", this.getIdioma()); |
121 | - entity.setDescricao(String.format(descricao, entity.getNumeroRescisao(), date, Util.convertBigDecimalToString(entity.getValorADevolver()))); | |
126 | + entity.setDescricao(String.format(descricao, numeroMask.length > 0 ? numeroMask[0] + "/" + ano : entity.getNumeroRescisao(), date, Util.convertBigDecimalToString(entity.getValorADevolver()))); | |
122 | 127 | }else{ |
123 | 128 | descricao = this.internacionalizacaoService.getTranslate("CONTRATOS.MSG.DESCRICAO_EVENTO_RESCISAO_CONTRATO_SEM_DEVOLUCAO_VALOR", this.getIdioma()); |
124 | - entity.setDescricao(String.format(descricao, entity.getNumeroRescisao(), date)); | |
129 | + entity.setDescricao(String.format(descricao, numeroMask.length > 0 ? numeroMask[0] + "/" + ano : entity.getNumeroRescisao(), date)); | |
125 | 130 | } |
126 | 131 | entity.setTipoEvento(this.dominioService.findByChaveAndCodigo(DominioContrato.TIPO_EVENTO_CONTRATO, DominioContrato.TIPO_EVENTO_RESCISAO)); |
127 | 132 | |
... | ... | @@ -237,4 +242,19 @@ public class EventoRescisaoContratoServiceImpl extends GenericServiceImpl<Evento |
237 | 242 | UtilDataBase.closeResources(inputSub); |
238 | 243 | } |
239 | 244 | } |
245 | + | |
246 | + private void configurarCodigo(EventoRescisaoContrato entitySaved) { | |
247 | + Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); | |
248 | + String ano = UtilDate.getAnoAtual(); | |
249 | + EventoRescisaoContrato ultimoRegistro = (EventoRescisaoContrato) this.eventoRescisaoContratoDao.buscarUltimoAnoRegistroComOrdenadoParametrizada("numeroRescisao", ano, usuarioLogado.getOrganizacao().getId()); | |
250 | + Long sequencial = null; | |
251 | + | |
252 | + if (UtilObjeto.isReferencia(ultimoRegistro)) { | |
253 | + sequencial = ultimoRegistro.getNumeroRescisao().replace(ano, "") == null ? null : Long.parseLong(ultimoRegistro.getNumeroRescisao().replace(ano, "") ); | |
254 | + }else{ | |
255 | + sequencial = 0l; | |
256 | + } | |
257 | + | |
258 | + entitySaved.setNumeroRescisao(StringUtils.leftPad((Long.valueOf(sequencial + 1)).toString(), 5, "0") + ano); | |
259 | + } | |
240 | 260 | } | ... | ... |
cit-contratos-api/src/main/resources/script-bd/v1.0.0-alpha10/01-cit-contratos-1.0.0-ALFA-10-postgres.sql
... | ... | @@ -172,5 +172,62 @@ BEGIN |
172 | 172 | END LOOP; |
173 | 173 | END$$; |
174 | 174 | |
175 | +DO $$ | |
176 | +DECLARE | |
177 | + r RECORD; | |
178 | +BEGIN | |
179 | + FOR r IN | |
180 | + SELECT | |
181 | + lpad(CAST(concat(CAST(row_number() over() AS VARCHAR), CAST(date_part('Year', (SELECT CURRENT_TIMESTAMP)) AS VARCHAR)) AS VARCHAR),9,'0') AS SEQUENCIALANO, ID as ID | |
182 | + FROM cnt_ev_repactuacao ORDER BY ID | |
183 | + LOOP | |
184 | + UPDATE cnt_ev_repactuacao SET numerorepactuacao = r.SEQUENCIALANO WHERE ID = r.ID; | |
185 | + END LOOP; | |
186 | +END$$; | |
187 | + | |
188 | +DO $$ | |
189 | +DECLARE | |
190 | + r RECORD; | |
191 | +BEGIN | |
192 | + FOR r IN | |
193 | + SELECT | |
194 | + concat(substring(descricao, 0, 23), lpad(CAST(concat(CAST(row_number() over() AS VARCHAR), CAST(date_part('Year', (SELECT CURRENT_TIMESTAMP)) AS VARCHAR)) AS VARCHAR),9,'0'), | |
195 | + ', ',substring(descricao, 34, length(descricao))) AS DESCRICAO, | |
196 | + ID as ID FROM cnt_cn_evento WHERE descricao like 'Repactuacao%' | |
197 | + LOOP | |
198 | + UPDATE cnt_cn_evento SET descricao = r.DESCRICAO WHERE ID = r.ID; | |
199 | + END LOOP; | |
200 | +END$$; | |
201 | + | |
202 | +DO $$ | |
203 | +DECLARE | |
204 | + r RECORD; | |
205 | +BEGIN | |
206 | + FOR r IN | |
207 | + SELECT | |
208 | + lpad(CAST(concat(CAST(row_number() over() AS VARCHAR), CAST(date_part('Year', (SELECT CURRENT_TIMESTAMP)) AS VARCHAR)) AS VARCHAR),9,'0') AS SEQUENCIALANO, ID as ID | |
209 | + FROM cnt_ev_rescisaocontrato ORDER BY ID | |
210 | + LOOP | |
211 | + UPDATE cnt_ev_rescisaocontrato SET numerorescisao = r.SEQUENCIALANO WHERE ID = r.ID; | |
212 | + END LOOP; | |
213 | +END$$; | |
214 | + | |
215 | +DO $$ | |
216 | +DECLARE | |
217 | + r RECORD; | |
218 | +BEGIN | |
219 | + FOR r IN | |
220 | + SELECT | |
221 | + concat(substring(descricao, 0, 26), lpad(CAST(concat(CAST(row_number() over() AS VARCHAR), CAST(date_part('Year', (SELECT CURRENT_TIMESTAMP)) AS VARCHAR)) AS VARCHAR),9,'0'), | |
222 | + ') ',substring(descricao, 34, length(descricao))) AS DESCRICAO, | |
223 | + ID as ID FROM cnt_cn_evento WHERE descricao like 'Rescisão%' | |
224 | + LOOP | |
225 | + UPDATE cnt_cn_evento SET descricao = r.DESCRICAO WHERE ID = r.ID; | |
226 | + END LOOP; | |
227 | +END$$; | |
228 | + | |
229 | + | |
230 | + | |
231 | + | |
175 | 232 | -- ERICK FIM 31/03/2016 |
176 | 233 | ... | ... |
cit-contratos-web/src/main/resources/reports/eventoRepactuacao.jrxml
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="eventoRepactuacao" pageWidth="554" pageHeight="802" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="554" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="2a9bde7e-349d-4f0b-b96c-98310606be6f"> |
3 | 3 | <property name="ireport.zoom" value="1.4641000000000042"/> |
4 | 4 | <property name="ireport.x" value="0"/> |
5 | - <property name="ireport.y" value="186"/> | |
5 | + <property name="ireport.y" value="0"/> | |
6 | 6 | <style name="table"> |
7 | 7 | <box> |
8 | 8 | <pen lineWidth="1.0" lineColor="#000000"/> |
... | ... | @@ -432,7 +432,8 @@ $F{cnpjfornecedorcontratada}.substring(12,14)]]></textFieldExpression> |
432 | 432 | <rightPen lineWidth="1.0"/> |
433 | 433 | </box> |
434 | 434 | <textElement textAlignment="Left" verticalAlignment="Middle"/> |
435 | - <textFieldExpression><![CDATA[$F{numerorepactuacao}]]></textFieldExpression> | |
435 | + <textFieldExpression><![CDATA[$F{numerorepactuacao}.substring(0,5) + "/" + | |
436 | +$F{numerorepactuacao}.substring(5,9)]]></textFieldExpression> | |
436 | 437 | </textField> |
437 | 438 | <staticText> |
438 | 439 | <reportElement positionType="Float" mode="Opaque" x="14" y="307" width="205" height="25" isPrintWhenDetailOverflows="true" backcolor="#CCCCCC" uuid="ff0d6117-4055-49cb-9040-887f3aaa90e2"/> | ... | ... |
cit-contratos-web/src/main/resources/reports/eventoRescisaoContrato.jrxml
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="encerramentoContrato" pageWidth="554" pageHeight="802" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="554" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="2a9bde7e-349d-4f0b-b96c-98310606be6f"> |
3 | 3 | <property name="ireport.zoom" value="2.000000000000001"/> |
4 | 4 | <property name="ireport.x" value="0"/> |
5 | - <property name="ireport.y" value="0"/> | |
5 | + <property name="ireport.y" value="144"/> | |
6 | 6 | <style name="table"> |
7 | 7 | <box> |
8 | 8 | <pen lineWidth="1.0" lineColor="#000000"/> |
... | ... | @@ -516,7 +516,8 @@ $F{cnpjcontratado}.substring(12,14)]]></textFieldExpression> |
516 | 516 | <rightPen lineWidth="1.0"/> |
517 | 517 | </box> |
518 | 518 | <textElement textAlignment="Left" verticalAlignment="Middle"/> |
519 | - <textFieldExpression><![CDATA[$F{numerorescisao}]]></textFieldExpression> | |
519 | + <textFieldExpression><![CDATA[$F{numerorescisao}.substring(0,5) + "/" + | |
520 | +$F{numerorescisao}.substring(5,9)]]></textFieldExpression> | |
520 | 521 | </textField> |
521 | 522 | <staticText> |
522 | 523 | <reportElement positionType="Float" mode="Opaque" x="15" y="307" width="205" height="25" backcolor="#CCCCCC" uuid="dacd172c-f3d1-4388-8ea4-d6adda659c51"/> | ... | ... |
cit-contratos-web/src/main/webapp/html/eventos/cnt_ev_repactuacao.html
... | ... | @@ -80,8 +80,8 @@ |
80 | 80 | </div> |
81 | 81 | <div class="row"> |
82 | 82 | <div class="col-sm-3"> |
83 | - <label-input-number ng-id="repactuacao.numeroRepactuacao" ng-label="CONTRATOS.LABEL.NUM_REPACTUACAO" ng-model="repactuacao.numeroRepactuacao" | |
84 | - form="formDialogRepactuacao" ng-obrigatorio="true" ng-disabled="!edit" ng-custom-maxlength="5" /> | |
83 | + <label-input ng-id="repactuacao.numeroRepactuacao" ng-label="CONTRATOS.LABEL.NUM_REPACTUACAO" ng-model="repactuacao.numeroRepactuacao" | |
84 | + form="formDialogRepactuacao" ng-mask="99999/9999" ng-obrigatorio="false" ng-disabled="true" /> | |
85 | 85 | </div><!-- .col-sm-3 --> |
86 | 86 | <div class="col-sm-3"> |
87 | 87 | <label-input-data ng-id="repactuacao.dataRepactuacao" ng-label="CONTRATOS.LABEL.DATA_REPACTUACAO" ng-disabled="!edit" | ... | ... |
cit-contratos-web/src/main/webapp/html/eventos/cnt_ev_rescisao_contrato.html
... | ... | @@ -117,8 +117,8 @@ |
117 | 117 | </div> |
118 | 118 | <div class="row"> |
119 | 119 | <div class="col-sm-3"> |
120 | - <label-input-number ng-id="rescisaoContrato.numeroRescisao" ng-label="CONTRATOS.RESCISAO_CONTRATO.NUM_RESCISAO" ng-model="rescisaoContrato.numeroRescisao" | |
121 | - form="formDialogRescisaoContrato" ng-obrigatorio="true" ng-disabled="!edit || rescisaoContrato.id" ng-custom-maxlength="6" /> | |
120 | + <label-input ng-id="rescisaoContrato.numeroRescisao" ng-label="CONTRATOS.RESCISAO_CONTRATO.NUM_RESCISAO" ng-model="rescisaoContrato.numeroRescisao" | |
121 | + form="formDialogRescisaoContrato" ng-obrigatorio="false" ng-disabled="true" ng-mask="99999/9999"/> | |
122 | 122 | </div> |
123 | 123 | <div class="col-sm-3"> |
124 | 124 | <label-input-data ng-id="rescisaoContrato.dataRescisao" | ... | ... |