Commit 69ad431ced7ccc6a18fd9ad83de440891c01a2c1
1 parent
28789efd
Exists in
master
[Redmine Atendimento #4206]Encerramento contrato - máscara
Showing
6 changed files
with
61 additions
and
50 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EncerramentoContratoServiceImpl.java
... | ... | @@ -26,10 +26,11 @@ import br.com.centralit.api.service.UsuarioService; |
26 | 26 | import br.com.centralit.framework.model.Usuario; |
27 | 27 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
28 | 28 | import br.com.centralit.framework.util.UtilColecao; |
29 | +import br.com.centralit.framework.util.UtilDate; | |
29 | 30 | import br.com.centralit.framework.util.UtilObjeto; |
30 | 31 | |
31 | 32 | /** |
32 | - * | |
33 | + * | |
33 | 34 | * <p><img src="http://centralit.com.br/images/logo_central.png"></p> |
34 | 35 | * |
35 | 36 | * <p><b>Company: </b> Central IT - Governança Corporativa - </p> |
... | ... | @@ -37,11 +38,11 @@ import br.com.centralit.framework.util.UtilObjeto; |
37 | 38 | * <p><b>Title: </b></p> |
38 | 39 | * |
39 | 40 | * <p><b>Description: </b></p> |
40 | - * | |
41 | + * | |
41 | 42 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
42 | 43 | * |
43 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
44 | - * | |
44 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
45 | + * | |
45 | 46 | * @since 24/02/2016 - 15:51:45 |
46 | 47 | * |
47 | 48 | * @version 1.0.0 |
... | ... | @@ -54,22 +55,22 @@ public class EncerramentoContratoServiceImpl extends GenericServiceImpl<Encerram |
54 | 55 | |
55 | 56 | /** Atributo contratoDao. */ |
56 | 57 | private EncerramentoContratoDao encerramentoContratoDao; |
57 | - | |
58 | + | |
58 | 59 | @Autowired |
59 | 60 | private ContratoService contratoService; |
60 | - | |
61 | + | |
61 | 62 | @Autowired |
62 | 63 | private OrganizacaoService organizacaoService; |
63 | - | |
64 | + | |
64 | 65 | @Autowired |
65 | 66 | private UsuarioService usuarioService; |
66 | - | |
67 | + | |
67 | 68 | @Autowired |
68 | 69 | private DominioService dominioService; |
69 | - | |
70 | + | |
70 | 71 | @Autowired |
71 | 72 | private ParceiroService parceiroService; |
72 | - | |
73 | + | |
73 | 74 | @Autowired |
74 | 75 | private AnexoService anexoService; |
75 | 76 | |
... | ... | @@ -87,7 +88,7 @@ public class EncerramentoContratoServiceImpl extends GenericServiceImpl<Encerram |
87 | 88 | |
88 | 89 | this.validator = validator; |
89 | 90 | } |
90 | - | |
91 | + | |
91 | 92 | /** |
92 | 93 | * {@inheritDoc} |
93 | 94 | */ |
... | ... | @@ -95,15 +96,15 @@ public class EncerramentoContratoServiceImpl extends GenericServiceImpl<Encerram |
95 | 96 | public EncerramentoContrato save(EncerramentoContrato encerramentoContrato) { |
96 | 97 | |
97 | 98 | this.montarObjeto(encerramentoContrato); |
98 | - | |
99 | + | |
99 | 100 | configurarNumeroTermo(encerramentoContrato);; |
100 | - | |
101 | + | |
101 | 102 | if (!UtilObjeto.isReferencia(encerramentoContrato.getNumTermo()) && UtilObjeto.isReferencia(encerramentoContrato.getDataEmissao())) { |
102 | 103 | encerramentoContrato.setNumTermo(this.geraNumeroTermo(encerramentoContrato.getDataEmissao())); |
103 | 104 | } |
104 | - | |
105 | + | |
105 | 106 | this.validarEntidade(encerramentoContrato, this.validator); |
106 | - | |
107 | + | |
107 | 108 | return super.save(encerramentoContrato); |
108 | 109 | } |
109 | 110 | |
... | ... | @@ -114,18 +115,18 @@ public class EncerramentoContratoServiceImpl extends GenericServiceImpl<Encerram |
114 | 115 | public EncerramentoContrato merge(EncerramentoContrato encerramentoContrato) { |
115 | 116 | |
116 | 117 | this.montarObjeto(encerramentoContrato); |
117 | - | |
118 | + | |
118 | 119 | this.validarEntidade(encerramentoContrato, this.validator); |
119 | 120 | |
120 | 121 | return super.save(encerramentoContrato); |
121 | 122 | |
122 | 123 | } |
123 | - | |
124 | + | |
124 | 125 | /** |
125 | - * | |
126 | + * | |
126 | 127 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
127 | 128 | * |
128 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
129 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
129 | 130 | * |
130 | 131 | * Método responsável por |
131 | 132 | * |
... | ... | @@ -145,9 +146,9 @@ public class EncerramentoContratoServiceImpl extends GenericServiceImpl<Encerram |
145 | 146 | if (UtilObjeto.isReferencia(encerramentoContrato.getContratante())) { |
146 | 147 | encerramentoContrato.setContratante(this.organizacaoService.find(encerramentoContrato.getContratante().getId())); |
147 | 148 | } |
148 | - | |
149 | + | |
149 | 150 | } |
150 | - | |
151 | + | |
151 | 152 | /** |
152 | 153 | * Método responsável por resolver os transients de documentos e observacoes |
153 | 154 | * |
... | ... | @@ -227,19 +228,18 @@ public class EncerramentoContratoServiceImpl extends GenericServiceImpl<Encerram |
227 | 228 | * @param entity |
228 | 229 | */ |
229 | 230 | private void configurarNumeroTermo(EncerramentoContrato entity) { |
230 | - | |
231 | - EncerramentoContrato ultimoRegistro = (EncerramentoContrato) encerramentoContratoDao.buscarUltimoRegistroComOrdenadoParametrizada("numTermo"); | |
232 | 231 | |
233 | - Long sequencial = 0L; | |
232 | + String ano = UtilDate.getAnoAtual(); | |
233 | + EncerramentoContrato ultimoRegistro = (EncerramentoContrato) encerramentoContratoDao.buscarUltimoAnoRegistroComOrdenadoParametrizada("numTermo", ano, null); | |
234 | + Long sequencial = null; | |
235 | + | |
234 | 236 | if (UtilObjeto.isReferencia(ultimoRegistro)) { |
235 | - sequencial = ultimoRegistro.getNumTermo() == null ? 0 : Long.parseLong(ultimoRegistro.getNumTermo().substring(0, 4)); | |
236 | - } | |
237 | - | |
238 | - Calendar calendar = Calendar.getInstance(); | |
239 | - String anoAtual = String.valueOf(calendar.get(Calendar.YEAR)); | |
240 | - String codigo = StringUtils.leftPad((++sequencial).toString(), 4, "0"); | |
241 | - | |
242 | - entity.setNumTermo(codigo.concat(anoAtual)); | |
237 | + sequencial = ultimoRegistro.getNumTermo().replace(ano, "") == null ? null : Long.parseLong(ultimoRegistro.getNumTermo().replace(ano, "") ); | |
238 | + }else{ | |
239 | + sequencial = 0l; | |
240 | + } | |
241 | + | |
242 | + entity.setNumTermo(StringUtils.leftPad((Long.valueOf(sequencial + 1)).toString(), 5, "0") + ano); | |
243 | 243 | } |
244 | 244 | |
245 | 245 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/validation/EncerramentoContratoValidator.java
... | ... | @@ -10,7 +10,7 @@ import br.com.centralit.framework.exception.CodigoErro; |
10 | 10 | import br.com.centralit.framework.util.UtilObjeto; |
11 | 11 | |
12 | 12 | /** |
13 | - * | |
13 | + * | |
14 | 14 | * <p><img src="http://centralit.com.br/images/logo_central.png"></p> |
15 | 15 | * |
16 | 16 | * <p><b>Company: </b> Central IT - Governança Corporativa - </p> |
... | ... | @@ -18,11 +18,11 @@ import br.com.centralit.framework.util.UtilObjeto; |
18 | 18 | * <p><b>Title: </b></p> |
19 | 19 | * |
20 | 20 | * <p><b>Description: </b></p> |
21 | - * | |
21 | + * | |
22 | 22 | * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> |
23 | 23 | * |
24 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
25 | - * | |
24 | + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
25 | + * | |
26 | 26 | * @since 24/02/2016 - 15:53:35 |
27 | 27 | * |
28 | 28 | * @version 1.0.0 |
... | ... | @@ -43,9 +43,9 @@ public class EncerramentoContratoValidator implements Validator { |
43 | 43 | public void validate(Object target, Errors errors) { |
44 | 44 | |
45 | 45 | ValidationUtils.rejectIfEmpty(errors, "contrato", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.NUM_CONTRATO"); |
46 | - | |
46 | + | |
47 | 47 | ValidationUtils.rejectIfEmpty(errors, "contratante", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.SELECIONE_CONTRATANTE"); |
48 | - | |
48 | + | |
49 | 49 | ValidationUtils.rejectIfEmpty(errors, "numTermo", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.NUM_TERMO_ANO"); |
50 | 50 | |
51 | 51 | ValidationUtils.rejectIfEmpty(errors, "dataEmissao", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.DATA_EMISSAO"); |
... | ... | @@ -57,15 +57,15 @@ public class EncerramentoContratoValidator implements Validator { |
57 | 57 | ValidationUtils.rejectIfEmpty(errors, "encaminhamentos", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.ENCAMINHAMENTOS"); |
58 | 58 | |
59 | 59 | ValidationUtils.rejectIfEmpty(errors, "decisao", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.DECISAO"); |
60 | - | |
60 | + | |
61 | 61 | EncerramentoContrato encerramento = (EncerramentoContrato) target; |
62 | - | |
62 | + | |
63 | 63 | if (UtilObjeto.isReferencia(encerramento.getContrato()) && UtilObjeto.isReferencia(encerramento.getDataEmissao())) { |
64 | 64 | if (encerramento.getDataEmissao().before(encerramento.getContrato().getDataUltimaVigenciaFinal())) { |
65 | 65 | errors.rejectValue("dataEmissao", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "VALIDACAO.DATA_EMISSAO_MENOR_VIGENCIA_FINAL"); |
66 | 66 | } |
67 | 67 | } |
68 | - | |
68 | + | |
69 | 69 | } |
70 | 70 | } |
71 | 71 | ... | ... |
cit-contratos-api/src/main/resources/script-bd/v1.0.0-alpha10/01-cit-contratos-1.0.0-ALFA-10-postgres.sql
... | ... | @@ -87,5 +87,16 @@ BEGIN |
87 | 87 | END LOOP; |
88 | 88 | END$$; |
89 | 89 | |
90 | +DO $$ | |
91 | +DECLARE | |
92 | + r RECORD; | |
93 | +BEGIN | |
94 | + FOR r IN | |
95 | + SELECT lpad(numtermo,9,'0') AS SEQUENCIALANO , ID as ID FROM cnt_encerramentocontrato | |
96 | + LOOP | |
97 | + UPDATE cnt_encerramentocontrato SET numtermo = r.SEQUENCIALANO WHERE ID = r.ID; | |
98 | + END LOOP; | |
99 | +END$$; | |
100 | + | |
90 | 101 | -- ERICK FIM 31/03/2016 |
91 | 102 | ... | ... |
cit-contratos-web/src/main/resources/reports/encerramentoContrato.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="1.3636363636363635"/> |
4 | 4 | <property name="ireport.x" value="0"/> |
5 | - <property name="ireport.y" value="686"/> | |
5 | + <property name="ireport.y" value="0"/> | |
6 | 6 | <style name="table"> |
7 | 7 | <box> |
8 | 8 | <pen lineWidth="1.0" lineColor="#000000"/> |
... | ... | @@ -111,7 +111,7 @@ |
111 | 111 | <textElement textAlignment="Left" verticalAlignment="Middle"> |
112 | 112 | <font isBold="false"/> |
113 | 113 | </textElement> |
114 | - <textFieldExpression><![CDATA[$F{numtermo}.substring(0,4) + "/" + $F{numtermo}.substring(4,8)]]></textFieldExpression> | |
114 | + <textFieldExpression><![CDATA[$F{numtermo}.substring(0,5) + "/" + $F{numtermo}.substring(5,9)]]></textFieldExpression> | |
115 | 115 | </textField> |
116 | 116 | </frame> |
117 | 117 | <frame> | ... | ... |
cit-contratos-web/src/main/webapp/assets/js/angular/custom/controller/EncerramentoContratoListController.js
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 3 | citApp.controller('EncerramentoContratoListController', ['$scope', 'EncerramentoContratoRepository', '$translate', |
4 | 4 | function EncerramentoContratoListController($scope, EncerramentoContratoRepository, $translate) { |
5 | - | |
5 | + | |
6 | 6 | $scope.resetForm = function(){ |
7 | 7 | angular.element("#encerramentoContratoControllerId").scope().resetForm(); |
8 | 8 | }; |
... | ... | @@ -30,9 +30,9 @@ citApp.controller('EncerramentoContratoListController', ['$scope', 'Encerramento |
30 | 30 | },{ |
31 | 31 | value : 'numTermo', |
32 | 32 | title : $translate.instant('LABEL.NUM_TERMO'), |
33 | - filter : 'maskTermoEncerramento', | |
34 | 33 | tamanho : 8, |
35 | - align : 'text-center' | |
34 | + align : 'text-center', | |
35 | + mask : [new RegExp(/(\d{2})(\d{1,4})$/), '$1/$2'] | |
36 | 36 | }]; |
37 | 37 | |
38 | 38 | // default criteria that will be sent to the server |
... | ... | @@ -47,7 +47,7 @@ citApp.controller('EncerramentoContratoListController', ['$scope', 'Encerramento |
47 | 47 | {type: 'date-range', field: 'dataEmissao'}, |
48 | 48 | {type: 'string', field: 'numTermo'}] |
49 | 49 | }; |
50 | - | |
50 | + | |
51 | 51 | // abrir uma EncerramentoContrato para visualizar ou editar dependendo do parametro edit |
52 | 52 | $scope.abrirEncerramentoContrato = function(edit){ |
53 | 53 | // recupera a EncerramentoContrato selecionada |
... | ... | @@ -77,9 +77,9 @@ citApp.controller('EncerramentoContratoListController', ['$scope', 'Encerramento |
77 | 77 | $scope.url = '/cit-contratos-web/rest/encerramentoContrato/gerarTermoEncerramentoContrato?idEncerramentoContrato='+ $scope.encerramentoContratoChecked.id; |
78 | 78 | $scope.visualizarRelatorio($scope.url, $translate.instant("LABEL.TITULO_ENCERRAMENTO_CONTRATO")); |
79 | 79 | } |
80 | - | |
80 | + | |
81 | 81 | }; |
82 | - | |
82 | + | |
83 | 83 | }]); |
84 | 84 | |
85 | 85 | ... | ... |
cit-contratos-web/src/main/webapp/html/encerramentoContrato/encerramentoContratoPg2.html
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | |
8 | 8 | <div class="row"> |
9 | 9 | <div class="col-sm-3"> |
10 | - <label-input ng-id="encerramentoContrato.numTermo" ng-label="LABEL.NUM_TERMO_ANO" ng-mask="9999/9999" | |
10 | + <label-input ng-id="encerramentoContrato.numTermo" ng-label="LABEL.NUM_TERMO_ANO" ng-mask="99999/9999" | |
11 | 11 | ng-model="encerramentoContrato.numTermo" form="termoEncerramentoForm" ng-disabled="true"/> |
12 | 12 | </div><!-- .col-sm-3 --> |
13 | 13 | ... | ... |