Commit 5ccb5d411e452032b2b90e355f8258d1fdb6876e
1 parent
cf317557
Exists in
master
[Redmine Atendimento #4206] Máscara Nº da Ocorrência
Showing
2 changed files
with
13 additions
and
1 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/RegistroOcorrenciaServiceImpl.java
... | ... | @@ -21,6 +21,7 @@ import net.sf.jasperreports.engine.design.JasperDesign; |
21 | 21 | import net.sf.jasperreports.engine.xml.JRXmlLoader; |
22 | 22 | |
23 | 23 | import org.apache.commons.collections.CollectionUtils; |
24 | +import org.apache.commons.lang.StringUtils; | |
24 | 25 | import org.apache.log4j.Logger; |
25 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
26 | 27 | import org.springframework.beans.factory.annotation.Qualifier; |
... | ... | @@ -219,7 +220,8 @@ public class RegistroOcorrenciaServiceImpl extends GenericServiceImpl<RegistroOc |
219 | 220 | } else { |
220 | 221 | sequencial = 1l; |
221 | 222 | } |
222 | - String numeroAnoOcorrencia = sequencial.toString() + entity.getDataEmissaoOcorrencia().get(Calendar.YEAR); | |
223 | + | |
224 | + String numeroAnoOcorrencia = StringUtils.leftPad((Long.valueOf(sequencial.toString())).toString(), 5, "0") + entity.getDataEmissaoOcorrencia().get(Calendar.YEAR); | |
223 | 225 | RegistroSequencial registroSequencial = new RegistroSequencial(sequencial, numeroAnoOcorrencia); |
224 | 226 | entity.setRegistroOcorrenciaSequencial(registroSequencial); |
225 | 227 | } | ... | ... |
cit-contratos-api/src/main/resources/script-bd/v1.0.0-alpha10/01-cit-contratos-1.0.0-ALFA-10-postgres.sql
... | ... | @@ -65,6 +65,16 @@ BEGIN |
65 | 65 | END LOOP; |
66 | 66 | END$$; |
67 | 67 | |
68 | +DO $$ | |
69 | +DECLARE | |
70 | + r RECORD; | |
71 | +BEGIN | |
72 | + FOR r IN | |
73 | + SELECT lpad(sequencialano,9,'0') AS SEQUENCIALANO , ID as ID FROM cnt_registroocorrencia | |
74 | + LOOP | |
75 | + UPDATE cnt_registroocorrencia SET sequencialano = r.SEQUENCIALANO WHERE ID = r.ID; | |
76 | + END LOOP; | |
77 | +END$$; | |
68 | 78 | |
69 | 79 | -- ERICK FIM 31/03/2016 |
70 | 80 | ... | ... |