Commit 259f370291740fe2d9865634c72603ec123de6e8
1 parent
d11706e4
Exists in
master
Atendimento #4999
Showing
3 changed files
with
12 additions
and
10 deletions
Show diff stats
cit-almoxarifado-api/src/main/java/br/com/centralit/api/model/AtendimentoRequisicaoConsumoItem.java
... | ... | @@ -184,7 +184,7 @@ public class AtendimentoRequisicaoConsumoItem extends PersistentObjectAuditOrgan |
184 | 184 | |
185 | 185 | if(atendimentoRequisicaoConsumoItemEnderecos != null){ |
186 | 186 | for(AtendimentoRequisicaoConsumoItemEndereco itemEndereco : atendimentoRequisicaoConsumoItemEnderecos){ |
187 | - quantidade = quantidade.add(itemEndereco.getQuantidade()); | |
187 | + quantidade = quantidade.add(itemEndereco.getQuantidade() != null ? itemEndereco.getQuantidade() : BigDecimal.ZERO); | |
188 | 188 | } |
189 | 189 | } |
190 | 190 | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/MovimentoEstoqueServiceImpl.java
... | ... | @@ -2,6 +2,7 @@ package br.com.centralit.api.service.impl; |
2 | 2 | |
3 | 3 | import java.math.BigDecimal; |
4 | 4 | import java.math.RoundingMode; |
5 | +import java.sql.Timestamp; | |
5 | 6 | import java.util.ArrayList; |
6 | 7 | import java.util.Calendar; |
7 | 8 | import java.util.Collection; |
... | ... | @@ -55,6 +56,7 @@ import br.com.centralit.framework.model.Usuario; |
55 | 56 | import br.com.centralit.framework.model.arquitetura.PersistentObjectAudit; |
56 | 57 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
57 | 58 | import br.com.centralit.framework.util.UtilColecao; |
59 | +import br.com.centralit.framework.util.UtilDate; | |
58 | 60 | import br.com.centralit.framework.util.UtilObjeto; |
59 | 61 | |
60 | 62 | /** |
... | ... | @@ -513,15 +515,15 @@ public class MovimentoEstoqueServiceImpl extends GenericServiceImpl<MovimentoEst |
513 | 515 | |
514 | 516 | Map<String, List<BigDecimal>> mapaDeMesesPorQuantidade = new HashMap<String, List<BigDecimal>>(); |
515 | 517 | |
516 | - for (ArrayList<Object> listaPropriedades : valoresAtendidos) { | |
517 | - | |
518 | + for (Object list : valoresAtendidos) { | |
519 | + Object[] listaPropriedades = (Object[]) list; | |
518 | 520 | if (mensal) { |
519 | 521 | |
520 | 522 | this.divideValoresPorMesEAno(listaPropriedades, mapaDeMesesPorQuantidade); |
521 | 523 | |
522 | 524 | } else { |
523 | 525 | |
524 | - result = result.add((BigDecimal) listaPropriedades.get(ATENDIMENTO_REQUISICAO_CONSUMO_ITEM_QUANTIDADE)); | |
526 | + result = result.add(listaPropriedades[ATENDIMENTO_REQUISICAO_CONSUMO_ITEM_QUANTIDADE] != null ? (BigDecimal) listaPropriedades[ATENDIMENTO_REQUISICAO_CONSUMO_ITEM_QUANTIDADE] : BigDecimal.ZERO); | |
525 | 527 | |
526 | 528 | } |
527 | 529 | } |
... | ... | @@ -556,7 +558,7 @@ public class MovimentoEstoqueServiceImpl extends GenericServiceImpl<MovimentoEst |
556 | 558 | |
557 | 559 | for(BigDecimal valor : mapaDeMesesPorQuantidade.get(chave)){ |
558 | 560 | |
559 | - valorSomadoMensal = valorSomadoMensal.add(valor); | |
561 | + valorSomadoMensal = valorSomadoMensal.add(valor != null ? valor : BigDecimal.ZERO); | |
560 | 562 | |
561 | 563 | } |
562 | 564 | |
... | ... | @@ -578,9 +580,9 @@ public class MovimentoEstoqueServiceImpl extends GenericServiceImpl<MovimentoEst |
578 | 580 | * @param mapaDeMesesPorQuantidade2 |
579 | 581 | * @return |
580 | 582 | */ |
581 | - private void divideValoresPorMesEAno(ArrayList<Object> listaPropriedades, Map<String, List<BigDecimal>> mapaDeMesesPorQuantidade) { | |
582 | - | |
583 | - Calendar data = (Calendar) listaPropriedades.get(ATENDIMENTO_REQUISICAO_CONSUMO_ITEM_ATENDIMENTO_REQUISICAO_CONSUMO_DATA_ATENDIMENTO); | |
583 | + private void divideValoresPorMesEAno(Object[] listaPropriedades, Map<String, List<BigDecimal>> mapaDeMesesPorQuantidade) { | |
584 | + | |
585 | + Calendar data = UtilDate.getCalendarDoTimestamp((Timestamp) listaPropriedades[ATENDIMENTO_REQUISICAO_CONSUMO_ITEM_ATENDIMENTO_REQUISICAO_CONSUMO_DATA_ATENDIMENTO]); | |
584 | 586 | |
585 | 587 | Integer mes = data.get(Calendar.MONTH); |
586 | 588 | |
... | ... | @@ -593,7 +595,7 @@ public class MovimentoEstoqueServiceImpl extends GenericServiceImpl<MovimentoEst |
593 | 595 | mapaDeMesesPorQuantidade.put(chave, new ArrayList<BigDecimal>()); |
594 | 596 | } |
595 | 597 | |
596 | - BigDecimal valor = (BigDecimal) listaPropriedades.get(ATENDIMENTO_REQUISICAO_CONSUMO_ITEM_QUANTIDADE); | |
598 | + BigDecimal valor = (BigDecimal) listaPropriedades[ATENDIMENTO_REQUISICAO_CONSUMO_ITEM_QUANTIDADE]; | |
597 | 599 | |
598 | 600 | mapaDeMesesPorQuantidade.get(chave).add(valor); |
599 | 601 | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/validation/RequisicaoConsumoItemValidator.java
... | ... | @@ -22,7 +22,7 @@ public class RequisicaoConsumoItemValidator implements Validator { |
22 | 22 | |
23 | 23 | ValidationUtils.rejectIfEmpty(errors, "requisicaoConsumo", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "ALMOXARIFADO.LABEL.REQUISICAOCONSUMO"); |
24 | 24 | |
25 | - ValidationUtils.rejectIfEmpty(errors, "material", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.MATERIAL"); | |
25 | + ValidationUtils.rejectIfEmpty(errors, "materialConsumo", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.MATERIAL"); | |
26 | 26 | |
27 | 27 | ValidationUtils.rejectIfEmpty(errors, "quantidade", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "ALMOXARIFADO.LABEL.QUANTIDADE"); |
28 | 28 | ... | ... |