Rev 195 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 195 | Rev 545 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | import java.util.ArrayList; |
4 | import java.util.ArrayList; |
| - | 5 | import java.util.Date; |
|
| 5 | import java.util.List; |
6 | import java.util.List; |
| 6 | 7 | ||
| 7 | import javax.faces.context.FacesContext; |
8 | import javax.faces.context.FacesContext; |
| 8 | import javax.inject.Inject; |
9 | import javax.inject.Inject; |
| 9 | import javax.inject.Named; |
10 | import javax.inject.Named; |
| Line 13... | Line 14... | ||
| 13 | import org.springframework.context.annotation.Scope; |
14 | import org.springframework.context.annotation.Scope; |
| 14 | 15 | ||
| 15 | import br.com.ec.core.consulta.ParametrosConsulta; |
16 | import br.com.ec.core.consulta.ParametrosConsulta; |
| 16 | import br.com.ec.core.exception.NegocioException; |
17 | import br.com.ec.core.exception.NegocioException; |
| 17 | import br.com.ec.core.generic.GenericService; |
18 | import br.com.ec.core.generic.GenericService; |
| - | 19 | import br.com.ec.core.util.DataUtils; |
|
| 18 | import br.com.ec.core.util.VerificadorUtil; |
20 | import br.com.ec.core.util.VerificadorUtil; |
| 19 | import br.com.ec.domain.dto.EtiquetaDTO; |
21 | import br.com.ec.domain.dto.EtiquetaDTO; |
| 20 | import br.com.ec.domain.model.Compra; |
22 | import br.com.ec.domain.model.Compra; |
| 21 | import br.com.ec.domain.model.CompraProduto; |
23 | import br.com.ec.domain.model.CompraProduto; |
| - | 24 | import br.com.ec.domain.model.EstoqueAuditoria; |
|
| 22 | import br.com.ec.domain.model.Produto; |
25 | import br.com.ec.domain.model.Produto; |
| 23 | import br.com.ec.domain.service.compraproduto.CompraProdutoService; |
26 | import br.com.ec.domain.service.compraproduto.CompraProdutoService; |
| - | 27 | import br.com.ec.domain.service.estoqueauditoria.EstoqueAuditoriaService; |
|
| 24 | import br.com.ec.domain.service.etiqueta.EtiquetaService; |
28 | import br.com.ec.domain.service.etiqueta.EtiquetaService; |
| 25 | import br.com.ec.domain.service.produto.ProdutoService; |
29 | import br.com.ec.domain.service.produto.ProdutoService; |
| 26 | import br.com.ec.domain.shared.ConstantesSEC; |
30 | import br.com.ec.domain.shared.ConstantesSEC; |
| 27 | import br.com.ec.domain.shared.Ordenador; |
31 | import br.com.ec.domain.shared.Ordenador; |
| 28 | import br.com.ec.domain.shared.OrdenadorImpl; |
32 | import br.com.ec.domain.shared.OrdenadorImpl; |
| Line 38... | Line 42... | ||
| 38 | private static final long serialVersionUID = 1L; |
42 | private static final long serialVersionUID = 1L; |
| 39 | 43 | ||
| 40 | private CompraProdutoService compraProdutoService; |
44 | private CompraProdutoService compraProdutoService; |
| 41 | private EtiquetaService etiquetaService; |
45 | private EtiquetaService etiquetaService; |
| 42 | private ProdutoService produtoService; |
46 | private ProdutoService produtoService; |
| - | 47 | private EstoqueAuditoriaService estoqueAuditoriaService; |
|
| 43 | 48 | ||
| 44 | private List<EtiquetaDTO> etiquetas; |
49 | private List<EtiquetaDTO> etiquetas; |
| 45 | private Long loteCompra; |
50 | private Long loteCompra; |
| 46 | private String codigoProduto; |
51 | private String codigoProduto; |
| 47 | private Ordenador ordenador; |
52 | private Ordenador ordenador; |
| - | 53 | ||
| - | 54 | private Date dataProducao; |
|
| - | 55 | private List<EstoqueAuditoria> ultimasProducoes; |
|
| 48 | 56 | ||
| 49 | @Inject |
57 | @Inject |
| 50 | public EtiquetaBean(CompraProdutoService compraProdutoService, EtiquetaService etiquetaService, ProdutoService produtoService) { |
- | |
| - | 58 | public EtiquetaBean(CompraProdutoService compraProdutoService, EtiquetaService etiquetaService, ProdutoService produtoService, |
|
| - | 59 | EstoqueAuditoriaService estoqueAuditoriaService) { |
|
| 51 | this.compraProdutoService = compraProdutoService; |
60 | this.compraProdutoService = compraProdutoService; |
| 52 | this.etiquetaService = etiquetaService; |
61 | this.etiquetaService = etiquetaService; |
| 53 | this.produtoService = produtoService; |
62 | this.produtoService = produtoService; |
| 54 | this.ordenador = new OrdenadorImpl(); |
63 | this.ordenador = new OrdenadorImpl(); |
| - | 64 | this.estoqueAuditoriaService = estoqueAuditoriaService; |
|
| 55 | }
|
65 | }
|
| 56 | 66 | ||
| 57 | @Override |
67 | @Override |
| 58 | public void preCarregamento() { |
68 | public void preCarregamento() { |
| 59 | entidade = new EtiquetaDTO(); |
69 | entidade = new EtiquetaDTO(); |
| Line 64... | Line 74... | ||
| 64 | @Override |
74 | @Override |
| 65 | public void limparEntidade() { |
75 | public void limparEntidade() { |
| 66 | EtiquetaDTO etiqueta = new EtiquetaDTO(); |
76 | EtiquetaDTO etiqueta = new EtiquetaDTO(); |
| 67 | setEntidade(etiqueta); |
77 | setEntidade(etiqueta); |
| 68 | setCodigoProduto(""); |
78 | setCodigoProduto(""); |
| - | 79 | setDataProducao(DataUtils.getDataAtual()); |
|
| 69 | }
|
80 | }
|
| 70 | 81 | ||
| 71 | @Override |
82 | @Override |
| 72 | public GenericService<EtiquetaDTO> getService() { |
83 | public GenericService<EtiquetaDTO> getService() { |
| 73 | return null; |
84 | return null; |
| Line 100... | Line 111... | ||
| 100 | public String getCodigoProduto() { |
111 | public String getCodigoProduto() { |
| 101 | return codigoProduto; |
112 | return codigoProduto; |
| 102 | }
|
113 | }
|
| 103 | public void setCodigoProduto(String codigoProduto) { |
114 | public void setCodigoProduto(String codigoProduto) { |
| 104 | this.codigoProduto = codigoProduto; |
115 | this.codigoProduto = codigoProduto; |
| - | 116 | }
|
|
| - | 117 | ||
| - | 118 | public Date getDataProducao() { |
|
| - | 119 | return dataProducao; |
|
| - | 120 | }
|
|
| - | 121 | public void setDataProducao(Date dataProducao) { |
|
| - | 122 | this.dataProducao = dataProducao; |
|
| - | 123 | }
|
|
| - | 124 | ||
| - | 125 | public List<EstoqueAuditoria> getUltimasProducoes() { |
|
| - | 126 | return ultimasProducoes; |
|
| - | 127 | }
|
|
| - | 128 | public void setUltimasProducoes(List<EstoqueAuditoria> ultimasProducoes) { |
|
| - | 129 | this.ultimasProducoes = ultimasProducoes; |
|
| 105 | }
|
130 | }
|
| 106 | 131 | ||
| 107 | /***************************************************************/
|
132 | /***************************************************************/
|
| 108 | 133 | ||
| 109 | public void prepararProdutosParaEtiquetas() { |
134 | public void prepararProdutosParaEtiquetas() { |
| Line 213... | Line 238... | ||
| 213 | return VerificadorUtil.naoEstaNulo(getEtiquetas()) ? getQuantidadeItens() > 0 ? ((getQuantidadeItens() / ConstantesSEC.Etiqueta.QUANTIDADE_MAXIMA_POR_FOLHA) + 1) : 0 : 0; |
238 | return VerificadorUtil.naoEstaNulo(getEtiquetas()) ? getQuantidadeItens() > 0 ? ((getQuantidadeItens() / ConstantesSEC.Etiqueta.QUANTIDADE_MAXIMA_POR_FOLHA) + 1) : 0 : 0; |
| 214 | }
|
239 | }
|
| 215 | 240 | ||
| 216 | public int getQuantidadeEtiquetasVazias() { |
241 | public int getQuantidadeEtiquetasVazias() { |
| 217 | return VerificadorUtil.naoEstaNulo(getEtiquetas()) ? getQuantidadeItens() > 0 ? (ConstantesSEC.Etiqueta.QUANTIDADE_MAXIMA_POR_FOLHA - (getQuantidadeItens() % ConstantesSEC.Etiqueta.QUANTIDADE_MAXIMA_POR_FOLHA)) : 0 : 0; |
242 | return VerificadorUtil.naoEstaNulo(getEtiquetas()) ? getQuantidadeItens() > 0 ? (ConstantesSEC.Etiqueta.QUANTIDADE_MAXIMA_POR_FOLHA - (getQuantidadeItens() % ConstantesSEC.Etiqueta.QUANTIDADE_MAXIMA_POR_FOLHA)) : 0 : 0; |
| - | 243 | }
|
|
| - | 244 | ||
| - | 245 | public void consultarUltimasProducoes() { |
|
| - | 246 | List<EstoqueAuditoria> ultimasProducoes = estoqueAuditoriaService.consultarUltimasProducoes(getDataProducao()); |
|
| - | 247 | setUltimasProducoes(ultimasProducoes); |
|
| - | 248 | }
|
|
| - | 249 | ||
| - | 250 | public void adicionarEtiquetasUltimasProducoes() { |
|
| - | 251 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 252 | public void execute() { |
|
| - | 253 | for (EstoqueAuditoria producao : getUltimasProducoes()) { |
|
| - | 254 | EtiquetaDTO etiqueta = new EtiquetaDTO(); |
|
| - | 255 | etiqueta.setProduto(producao.getProduto()); |
|
| - | 256 | etiqueta.setQuantidade(producao.getQuantidadeEstoqueNovo() - producao.getQuantidadeEstoqueAnterior()); |
|
| - | 257 | getEtiquetas().add(etiqueta); |
|
| - | 258 | }
|
|
| - | 259 | limparEntidade(); |
|
| - | 260 | LancadorMensagem.lancarSucesso("Etiqueta(s) adicionada(s) com sucesso!"); |
|
| - | 261 | }
|
|
| - | 262 | }); |
|
| 218 | }
|
263 | }
|
| 219 | 264 | ||
| 220 | }
|
265 | }
|