Commit dd1a4b775172d35baddf0ddfdcd12d721b26d316
1 parent
d3c080f5
Exists in
master
[Redmine Atendimento #4206]Alteração campo codigo cronograma Execucao
Showing
3 changed files
with
38 additions
and
27 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/model/CronogramaExecucao.java
... | ... | @@ -30,7 +30,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
30 | 30 | @Table(name="cnt_cronogramaexecucao") |
31 | 31 | public class CronogramaExecucao extends PersistentObjectAuditOrganizacao { |
32 | 32 | |
33 | - | |
33 | + | |
34 | 34 | private static final long serialVersionUID = 4447061172675458262L; |
35 | 35 | |
36 | 36 | @Id |
... | ... | @@ -38,10 +38,10 @@ public class CronogramaExecucao extends PersistentObjectAuditOrganizacao { |
38 | 38 | @JsonView({ Views.GenericView.class }) |
39 | 39 | private Long id; |
40 | 40 | |
41 | - @Column(length = 9, nullable=false) | |
41 | + @Column(length = 10, nullable=false) | |
42 | 42 | @JsonView({ ViewsContrato.CronogramaExecucaoEditView.class }) |
43 | 43 | private String codigo; |
44 | - | |
44 | + | |
45 | 45 | @ManyToOne(fetch = FetchType.LAZY, optional = false) |
46 | 46 | @JsonView({ ViewsContrato.CronogramaExecucaoEditView.class, ViewsContrato.ContratoAutoCompleteView.class }) |
47 | 47 | private Contrato contrato; |
... | ... | @@ -62,7 +62,7 @@ public class CronogramaExecucao extends PersistentObjectAuditOrganizacao { |
62 | 62 | @JsonDeserialize(using = MoneyDeserializer.class) |
63 | 63 | @JsonView({ ViewsContrato.CronogramaExecucaoEditView.class }) |
64 | 64 | private BigDecimal valorTotal; |
65 | - | |
65 | + | |
66 | 66 | @Override |
67 | 67 | public Long getId() { |
68 | 68 | return id; | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/CronogramaExecucaoServiceImpl.java
... | ... | @@ -101,13 +101,11 @@ public class CronogramaExecucaoServiceImpl extends GenericServiceImpl<Cronograma |
101 | 101 | public CronogramaExecucao save(CronogramaExecucao cronogramaExecucao) { |
102 | 102 | |
103 | 103 | validarEntidade(cronogramaExecucao, this.validator); |
104 | - | |
104 | + | |
105 | 105 | configurarCodigo(cronogramaExecucao); |
106 | - | |
106 | + | |
107 | 107 | montarObjetoCronograma(cronogramaExecucao); |
108 | - | |
109 | - configurarCodigo(cronogramaExecucao); | |
110 | - | |
108 | + | |
111 | 109 | validarDataEntregaNaVigenciaContrato(cronogramaExecucao); |
112 | 110 | |
113 | 111 | validarValorTotalItensAcimaValorContrato(cronogramaExecucao); |
... | ... | @@ -117,15 +115,15 @@ public class CronogramaExecucaoServiceImpl extends GenericServiceImpl<Cronograma |
117 | 115 | |
118 | 116 | @Override |
119 | 117 | public CronogramaExecucao merge(CronogramaExecucao cronogramaExecucao) { |
120 | - | |
118 | + | |
121 | 119 | validarEntidade(cronogramaExecucao, this.validator); |
122 | - | |
120 | + | |
123 | 121 | montarObjetoCronograma(cronogramaExecucao); |
124 | - | |
122 | + | |
125 | 123 | validarDataEntregaNaVigenciaContrato(cronogramaExecucao); |
126 | - | |
124 | + | |
127 | 125 | validarValorTotalItensAcimaValorContrato(cronogramaExecucao); |
128 | - | |
126 | + | |
129 | 127 | return (CronogramaExecucao) this.cronogramaExecucaoDao.merge(cronogramaExecucao); |
130 | 128 | } |
131 | 129 | |
... | ... | @@ -133,7 +131,7 @@ public class CronogramaExecucaoServiceImpl extends GenericServiceImpl<Cronograma |
133 | 131 | * Método responsável por gerar o relatório de cronograma de execução |
134 | 132 | * |
135 | 133 | * @author luis.camargo |
136 | - * | |
134 | + * | |
137 | 135 | * @param idCronograma |
138 | 136 | * @param download |
139 | 137 | * @param response |
... | ... | @@ -183,14 +181,14 @@ public class CronogramaExecucaoServiceImpl extends GenericServiceImpl<Cronograma |
183 | 181 | } finally { |
184 | 182 | UtilDataBase.closeResources(conn, input, inputSub, baos); |
185 | 183 | } |
186 | - } | |
184 | + } | |
187 | 185 | private void validarDataEntregaNaVigenciaContrato(CronogramaExecucao cronogramaExecucao) { |
188 | 186 | for (CronogramaExecucaoItem item : cronogramaExecucao.getItensCronogramaExecucao()) { |
189 | 187 | for (CronogramaExecucaoItemParcela parcela : item.getParcelas()) { |
190 | - | |
188 | + | |
191 | 189 | boolean isBefore = parcela.getDataEntrega().before(cronogramaExecucao.getContrato().getDataVigenciaInicial()); |
192 | 190 | boolean isAfter = parcela.getDataEntrega().after(cronogramaExecucao.getContrato().getDataUltimaVigenciaFinal()); |
193 | - | |
191 | + | |
194 | 192 | lancarBusinessException("CONTRATOS.VALIDACAO.DATA_ENTREGA_CRONOGRAMA_FORA_VIGENCIA", CodigoErro.REGRA_NEGOCIO.getValue(), (isBefore || isAfter)); |
195 | 193 | } |
196 | 194 | } |
... | ... | @@ -217,7 +215,7 @@ public class CronogramaExecucaoServiceImpl extends GenericServiceImpl<Cronograma |
217 | 215 | * @param entity |
218 | 216 | */ |
219 | 217 | private void configurarCodigo(CronogramaExecucao entity) { |
220 | - | |
218 | + | |
221 | 219 | if (!UtilObjeto.isReferencia(entity.getOrganizacao())) { |
222 | 220 | entity.setOrganizacao(this.getUsuario().getOrganizacao()); |
223 | 221 | } |
... | ... | @@ -227,11 +225,11 @@ public class CronogramaExecucaoServiceImpl extends GenericServiceImpl<Cronograma |
227 | 225 | Long sequencial = 0L; |
228 | 226 | if (UtilObjeto.isReferencia(ultimoRegistro)) { |
229 | 227 | sequencial = ultimoRegistro.getCodigo() == null ? 0 : Long.parseLong(ultimoRegistro.getCodigo().split("/")[0]); |
230 | - } | |
231 | - | |
228 | + } | |
229 | + | |
232 | 230 | Calendar calendar = Calendar.getInstance(); |
233 | 231 | String anoAtual = String.valueOf(calendar.get(Calendar.YEAR)); |
234 | - String codigo = StringUtils.leftPad((++sequencial).toString(), 4, "0"); | |
232 | + String codigo = StringUtils.leftPad((++sequencial).toString(), 5, "0"); | |
235 | 233 | |
236 | 234 | entity.setCodigo(codigo.concat("/").concat(anoAtual)); |
237 | 235 | } |
... | ... | @@ -239,22 +237,22 @@ public class CronogramaExecucaoServiceImpl extends GenericServiceImpl<Cronograma |
239 | 237 | private void montarObjetoCronograma(CronogramaExecucao cronogramaExecucao) { |
240 | 238 | |
241 | 239 | cronogramaExecucao.setContrato(contratoService.getReference(cronogramaExecucao.getContrato().getId())); |
242 | - | |
240 | + | |
243 | 241 | // resolve os transients dos documentos e observacoes do cronograma |
244 | 242 | montarDocsObsCronograma(cronogramaExecucao); |
245 | 243 | |
246 | 244 | // cria vinculo do CronogramaExecucao com as CronogramaExecucaoItem |
247 | 245 | for (CronogramaExecucaoItem itemCronograma : cronogramaExecucao.getItensCronogramaExecucao()) { |
248 | - | |
246 | + | |
249 | 247 | itemCronograma.setCronogramaExecucao(cronogramaExecucao); |
250 | - | |
248 | + | |
251 | 249 | // cria vinculo do CronogramaExecucaoItem com as CronogramaExecucaoItemParcela |
252 | 250 | for (CronogramaExecucaoItemParcela parcela : itemCronograma.getParcelas()) { |
253 | 251 | parcela.setCronogramaExecucaoItem(itemCronograma); |
254 | 252 | } |
255 | 253 | } |
256 | 254 | } |
257 | - | |
255 | + | |
258 | 256 | /** |
259 | 257 | * Método responsável por resolver os transients de documentos e observacoes |
260 | 258 | * | ... | ... |
cit-contratos-api/src/main/resources/script-bd/v1.0.0-alpha10/01-cit-contratos-1.0.0-ALFA-10-postgres.sql
... | ... | @@ -24,7 +24,6 @@ END$$; |
24 | 24 | |
25 | 25 | ALTER TABLE cnt_estudoTecnico DROP COLUMN codigo; |
26 | 26 | |
27 | - | |
28 | 27 | DO $$ |
29 | 28 | DECLARE |
30 | 29 | r RECORD; |
... | ... | @@ -37,5 +36,19 @@ BEGIN |
37 | 36 | END LOOP; |
38 | 37 | END$$; |
39 | 38 | |
39 | +ALTER TABLE cnt_cronogramaexecucao ALTER COLUMN codigo TYPE VARCHAR(10); | |
40 | + | |
41 | +DO $$ | |
42 | +DECLARE | |
43 | + r RECORD; | |
44 | +BEGIN | |
45 | + FOR r IN | |
46 | + SELECT lpad(codigo,10,'0') AS SEQUENCIALANO , ID as ID FROM cnt_cronogramaexecucao | |
47 | + LOOP | |
48 | + UPDATE cnt_cronogramaexecucao SET codigo = r.SEQUENCIALANO WHERE ID = r.ID; | |
49 | + END LOOP; | |
50 | +END$$; | |
51 | + | |
52 | + | |
40 | 53 | -- ERICK FIM 31/03/2016 |
41 | 54 | ... | ... |