Commit 523b5fca5218a92376535324ce2931cb79cf6899
1 parent
0fb7bd66
Exists in
master
Redmine #3903
Showing
3 changed files
with
27 additions
and
0 deletions
Show diff stats
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/EnderecoService.java
@@ -96,5 +96,7 @@ public interface EnderecoService extends GenericService<Endereco, Long> { | @@ -96,5 +96,7 @@ public interface EnderecoService extends GenericService<Endereco, Long> { | ||
96 | * @return | 96 | * @return |
97 | */ | 97 | */ |
98 | Endereco buscarEnderecoWSCorreio(String cep); | 98 | Endereco buscarEnderecoWSCorreio(String cep); |
99 | + | ||
100 | + String buscaUltimoCodigoEndereco(); | ||
99 | 101 | ||
100 | } | 102 | } |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/impl/EnderecoServiceImpl.java
@@ -284,6 +284,18 @@ public class EnderecoServiceImpl extends GenericServiceImpl<Endereco, Long> impl | @@ -284,6 +284,18 @@ public class EnderecoServiceImpl extends GenericServiceImpl<Endereco, Long> impl | ||
284 | 284 | ||
285 | entity.setCodigo(codigo); | 285 | entity.setCodigo(codigo); |
286 | } | 286 | } |
287 | + | ||
288 | + @Override | ||
289 | + public String buscaUltimoCodigoEndereco(){ | ||
290 | + Endereco ultimoRegistro = (Endereco) this.enderecoDao.buscarUltimoRegistroComOrdenadoParametrizada("codigo"); | ||
291 | + | ||
292 | + Long sequencial = null; | ||
293 | + if (UtilObjeto.isReferencia(ultimoRegistro)) { | ||
294 | + sequencial = ultimoRegistro.getCodigo() == null ? null : Long.parseLong(ultimoRegistro.getCodigo()); | ||
295 | + } | ||
296 | + | ||
297 | + return sequencial.toString(); | ||
298 | + } | ||
287 | 299 | ||
288 | /** | 300 | /** |
289 | * <p> | 301 | * <p> |
cit-tabelas-corp-api/src/main/java/br/com/centralit/api/service/impl/PessoaServiceImpl.java
@@ -23,6 +23,7 @@ import br.com.centralit.api.model.PessoaJuridica; | @@ -23,6 +23,7 @@ import br.com.centralit.api.model.PessoaJuridica; | ||
23 | import br.com.centralit.api.model.Portador; | 23 | import br.com.centralit.api.model.Portador; |
24 | import br.com.centralit.api.model.Telefone; | 24 | import br.com.centralit.api.model.Telefone; |
25 | import br.com.centralit.api.service.ColaboradorService; | 25 | import br.com.centralit.api.service.ColaboradorService; |
26 | +import br.com.centralit.api.service.ConfiguracaoParametroSistemaService; | ||
26 | import br.com.centralit.api.service.ContatoService; | 27 | import br.com.centralit.api.service.ContatoService; |
27 | import br.com.centralit.api.service.DominioService; | 28 | import br.com.centralit.api.service.DominioService; |
28 | import br.com.centralit.api.service.EnderecoService; | 29 | import br.com.centralit.api.service.EnderecoService; |
@@ -133,6 +134,10 @@ public class PessoaServiceImpl extends GenericServiceImpl<Pessoa, Long> implemen | @@ -133,6 +134,10 @@ public class PessoaServiceImpl extends GenericServiceImpl<Pessoa, Long> implemen | ||
133 | /** Atributo seguradoraService. */ | 134 | /** Atributo seguradoraService. */ |
134 | @Autowired | 135 | @Autowired |
135 | private SeguradoraService seguradoraService; | 136 | private SeguradoraService seguradoraService; |
137 | + | ||
138 | + /** Atributo configuracaoParametroSistemaService. */ | ||
139 | + @Autowired | ||
140 | + private ConfiguracaoParametroSistemaService configuracaoParametroSistemaService; | ||
136 | 141 | ||
137 | /** Atributo moduloService. */ | 142 | /** Atributo moduloService. */ |
138 | @Autowired | 143 | @Autowired |
@@ -399,12 +404,20 @@ public class PessoaServiceImpl extends GenericServiceImpl<Pessoa, Long> implemen | @@ -399,12 +404,20 @@ public class PessoaServiceImpl extends GenericServiceImpl<Pessoa, Long> implemen | ||
399 | telefone.setPessoa(pessoaVH.getPessoa()); | 404 | telefone.setPessoa(pessoaVH.getPessoa()); |
400 | 405 | ||
401 | } | 406 | } |
407 | + | ||
402 | // Percorre a lista de endereco para setar a referencia da pessoa | 408 | // Percorre a lista de endereco para setar a referencia da pessoa |
409 | + String ultimoCodigoEndereco = enderecoService.buscaUltimoCodigoEndereco(); | ||
403 | for (Endereco endereco : pessoaVH.getPessoa().getEnderecos()) { | 410 | for (Endereco endereco : pessoaVH.getPessoa().getEnderecos()) { |
404 | 411 | ||
405 | endereco.setPessoa(pessoaVH.getPessoa()); | 412 | endereco.setPessoa(pessoaVH.getPessoa()); |
413 | + | ||
414 | + if(endereco.getCodigo() == null || endereco.getCodigo().equals("")){ | ||
415 | + ultimoCodigoEndereco = configuracaoParametroSistemaService.gerarNumeroIdentificacaoSeguencial(Long.valueOf(ultimoCodigoEndereco)); | ||
416 | + endereco.setCodigo(ultimoCodigoEndereco); | ||
417 | + } | ||
406 | 418 | ||
407 | } | 419 | } |
420 | + | ||
408 | // Percorre a lista de contatos para setar a referencia de pessoa | 421 | // Percorre a lista de contatos para setar a referencia de pessoa |
409 | for (Contato contato : pessoaVH.getPessoa().getContatos()) { | 422 | for (Contato contato : pessoaVH.getPessoa().getContatos()) { |
410 | 423 |