Commit 00795e0233947891e0d27ce38da1306b7ddc2d3f
1 parent
03f19ad9
Exists in
master
Redmine #4935 Quantidade em estoque
Showing
6 changed files
with
35 additions
and
5 deletions
Show diff stats
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/MaterialLocalEstoqueDao.java
@@ -28,4 +28,6 @@ public interface MaterialLocalEstoqueDao extends CitGenericDAO { | @@ -28,4 +28,6 @@ public interface MaterialLocalEstoqueDao extends CitGenericDAO { | ||
28 | BigDecimal buscarQuantidadeLocalEstoquePorIdMaterialIdEndereco(Long idMaterial, Long idEndereco); | 28 | BigDecimal buscarQuantidadeLocalEstoquePorIdMaterialIdEndereco(Long idMaterial, Long idEndereco); |
29 | 29 | ||
30 | MaterialLocalEstoque buscarMaterialLocalEstoque(Long idMaterial, Long idEndereco); | 30 | MaterialLocalEstoque buscarMaterialLocalEstoque(Long idMaterial, Long idEndereco); |
31 | + | ||
32 | + BigDecimal buscaQuantidadeAtualMaterial(Long idMaterial, Long idOrganizacao); | ||
31 | } | 33 | } |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/impl/MaterialLocalEstoqueDaoHibernate.java
@@ -12,6 +12,7 @@ import br.com.centralit.api.model.EstruturaOrganizacional; | @@ -12,6 +12,7 @@ import br.com.centralit.api.model.EstruturaOrganizacional; | ||
12 | import br.com.centralit.api.model.MaterialLocalEstoque; | 12 | import br.com.centralit.api.model.MaterialLocalEstoque; |
13 | import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; | 13 | import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; |
14 | import br.com.centralit.framework.dao.arquitetura.SearchSeven; | 14 | import br.com.centralit.framework.dao.arquitetura.SearchSeven; |
15 | +import br.com.centralit.framework.util.UtilColecao; | ||
15 | 16 | ||
16 | /** | 17 | /** |
17 | * <p> | 18 | * <p> |
@@ -131,4 +132,23 @@ public class MaterialLocalEstoqueDaoHibernate extends CitGenericDAOImpl implemen | @@ -131,4 +132,23 @@ public class MaterialLocalEstoqueDaoHibernate extends CitGenericDAOImpl implemen | ||
131 | 132 | ||
132 | return this.searchUnique(search); | 133 | return this.searchUnique(search); |
133 | } | 134 | } |
135 | + | ||
136 | + @Override | ||
137 | + public BigDecimal buscaQuantidadeAtualMaterial(Long idMaterial, Long idOrganizacao) { | ||
138 | + | ||
139 | + SearchSeven search = new SearchSeven(); | ||
140 | + search.addField("quantidade"); | ||
141 | + search.addFilterEqual("materialEstoque.material.id", idMaterial); | ||
142 | + search.addFilterEqual("organizacao.id", idOrganizacao); | ||
143 | + | ||
144 | + List<BigDecimal> qtds = this.search(search); | ||
145 | + BigDecimal qnt = BigDecimal.ZERO; | ||
146 | + | ||
147 | + if(!UtilColecao.isVazio(qtds)){ | ||
148 | + for (BigDecimal quantidade : qtds) { | ||
149 | + qnt = qnt.add(quantidade); | ||
150 | + } | ||
151 | + } | ||
152 | + return qnt; | ||
153 | + } | ||
134 | } | 154 | } |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/MaterialLocalEstoqueService.java
@@ -28,4 +28,6 @@ public interface MaterialLocalEstoqueService extends GenericService<MaterialLoca | @@ -28,4 +28,6 @@ public interface MaterialLocalEstoqueService extends GenericService<MaterialLoca | ||
28 | BigDecimal buscarQuantidadeLocalEstoquePorIdMaterialIdEndereco(Long idMaterial, Long idEndereco); | 28 | BigDecimal buscarQuantidadeLocalEstoquePorIdMaterialIdEndereco(Long idMaterial, Long idEndereco); |
29 | 29 | ||
30 | MaterialLocalEstoque buscarMaterialLocalEstoque(Long idMaterial, Long idEndereco); | 30 | MaterialLocalEstoque buscarMaterialLocalEstoque(Long idMaterial, Long idEndereco); |
31 | + | ||
32 | + BigDecimal buscaQuantidadeAtualMaterial(Long idMaterial, Long idOrganizacao); | ||
31 | } | 33 | } |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/AtendimentoRequisicaoConsumoServiceImpl.java
@@ -401,6 +401,7 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< | @@ -401,6 +401,7 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< | ||
401 | atendimentoRequisicaoConsumoItemEndereco.setAtendimentoRequisicaoConsumoItem(atendimentoItem); | 401 | atendimentoRequisicaoConsumoItemEndereco.setAtendimentoRequisicaoConsumoItem(atendimentoItem); |
402 | if(atendimentoRequisicaoConsumoItemEndereco.getQuantidade() == null || atendimentoRequisicaoConsumoItemEndereco.getQuantidade().compareTo(new BigDecimal("0")) == 0){ | 402 | if(atendimentoRequisicaoConsumoItemEndereco.getQuantidade() == null || atendimentoRequisicaoConsumoItemEndereco.getQuantidade().compareTo(new BigDecimal("0")) == 0){ |
403 | atendimentoRequisicaoConsumoItemEndereco.setQuantidade(new BigDecimal(0)); | 403 | atendimentoRequisicaoConsumoItemEndereco.setQuantidade(new BigDecimal(0)); |
404 | + todosItensSemQuantidade = true; | ||
404 | }else{ | 405 | }else{ |
405 | todosItensSemQuantidade = false; | 406 | todosItensSemQuantidade = false; |
406 | } | 407 | } |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/MaterialLocalEstoqueServiceImpl.java
@@ -142,5 +142,10 @@ public class MaterialLocalEstoqueServiceImpl extends GenericServiceImpl<Material | @@ -142,5 +142,10 @@ public class MaterialLocalEstoqueServiceImpl extends GenericServiceImpl<Material | ||
142 | public MaterialLocalEstoque buscarMaterialLocalEstoque(Long idMaterial, Long idEndereco) { | 142 | public MaterialLocalEstoque buscarMaterialLocalEstoque(Long idMaterial, Long idEndereco) { |
143 | return this.materailLocalEstoqueDao.buscarMaterialLocalEstoque(idMaterial, idEndereco); | 143 | return this.materailLocalEstoqueDao.buscarMaterialLocalEstoque(idMaterial, idEndereco); |
144 | } | 144 | } |
145 | + | ||
146 | + @Override | ||
147 | + public BigDecimal buscaQuantidadeAtualMaterial(Long idMaterial, Long idOrganizacao) { | ||
148 | + return this.materailLocalEstoqueDao.buscaQuantidadeAtualMaterial(idMaterial, idOrganizacao); | ||
149 | + } | ||
145 | 150 | ||
146 | } | 151 | } |
cit-almoxarifado-web/src/main/java/br/com/centralit/controller/MaterialEstoqueSaldoController.java
@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.ResponseBody; | @@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.ResponseBody; | ||
12 | import br.com.centralit.api.model.Material; | 12 | import br.com.centralit.api.model.Material; |
13 | import br.com.centralit.api.model.MaterialEstoqueSaldo; | 13 | import br.com.centralit.api.model.MaterialEstoqueSaldo; |
14 | import br.com.centralit.api.service.MaterialEstoqueSaldoService; | 14 | import br.com.centralit.api.service.MaterialEstoqueSaldoService; |
15 | +import br.com.centralit.api.service.MaterialLocalEstoqueService; | ||
15 | import br.com.centralit.api.service.MovimentoEstoqueService; | 16 | import br.com.centralit.api.service.MovimentoEstoqueService; |
16 | import br.com.centralit.api.service.OrganizacaoService; | 17 | import br.com.centralit.api.service.OrganizacaoService; |
17 | import br.com.centralit.framework.controller.GenericController; | 18 | import br.com.centralit.framework.controller.GenericController; |
@@ -30,6 +31,9 @@ public class MaterialEstoqueSaldoController extends GenericController<MaterialEs | @@ -30,6 +31,9 @@ public class MaterialEstoqueSaldoController extends GenericController<MaterialEs | ||
30 | 31 | ||
31 | @Autowired | 32 | @Autowired |
32 | private MovimentoEstoqueService movimentoEstoqueService; | 33 | private MovimentoEstoqueService movimentoEstoqueService; |
34 | + | ||
35 | + @Autowired | ||
36 | + private MaterialLocalEstoqueService materialLocalEstoqueService; | ||
33 | 37 | ||
34 | @Autowired | 38 | @Autowired |
35 | public MaterialEstoqueSaldoController( MaterialEstoqueSaldoService materialEstoqueSaldoService ) { | 39 | public MaterialEstoqueSaldoController( MaterialEstoqueSaldoService materialEstoqueSaldoService ) { |
@@ -42,12 +46,8 @@ public class MaterialEstoqueSaldoController extends GenericController<MaterialEs | @@ -42,12 +46,8 @@ public class MaterialEstoqueSaldoController extends GenericController<MaterialEs | ||
42 | @ResponseBody | 46 | @ResponseBody |
43 | public BigDecimal buscaQuantidadeAtual(@RequestParam(value = "IdMaterial") String idMaterial, @RequestParam(value = "idOrganizacao") String idOrganizacao) { | 47 | public BigDecimal buscaQuantidadeAtual(@RequestParam(value = "IdMaterial") String idMaterial, @RequestParam(value = "idOrganizacao") String idOrganizacao) { |
44 | 48 | ||
45 | - Organizacao organizacao = this.organizacaoService.find(Long.parseLong(idOrganizacao)); | ||
46 | - | ||
47 | - BigDecimal quantidadeFechada = this.materialEstoqueSaldoService.buscaUltimaQuantidadeFechada(Long.parseLong(idMaterial), Long.parseLong(idOrganizacao)); | ||
48 | - BigDecimal quantidadeMesAtual = this.movimentoEstoqueService.buscaQuantidadeMovimentadaMaterialPorReferencia(Long.parseLong(idMaterial), organizacao.getDataReferenciaVigente(), Long.parseLong(idOrganizacao)); | 49 | + return this.materialLocalEstoqueService.buscaQuantidadeAtualMaterial(Long.valueOf(idMaterial), Long.valueOf(idOrganizacao)); |
49 | 50 | ||
50 | - return quantidadeFechada.add(quantidadeMesAtual); | ||
51 | } | 51 | } |
52 | 52 | ||
53 | @RequestMapping(value = "/buscaUltimoValorFechado", method = RequestMethod.GET, produces = "application/json") | 53 | @RequestMapping(value = "/buscaUltimoValorFechado", method = RequestMethod.GET, produces = "application/json") |