Rev 574 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 574 | blopes | 1 | package br.com.ec.domain.dto; |
| 2 | |||
| 3 | import java.util.Date; |
||
| 4 | |||
| 575 | blopes | 5 | import br.com.ec.core.util.VerificadorUtil; |
| 574 | blopes | 6 | import br.com.ec.domain.model.Fornecedor; |
| 7 | |||
| 8 | public class AnaliseVendaProdutoDTO { |
||
| 9 | |||
| 575 | blopes | 10 | private static final Integer QUANTIDADE_MESES_VENDAS_3 = 3; |
| 11 | |||
| 574 | blopes | 12 | private ProdutoDTO produtoDTO; |
| 13 | private Integer quantidadeEstoque; |
||
| 14 | private Integer quantidadeVendas; |
||
| 575 | blopes | 15 | private Integer quantidadeVendasAposCompra; |
| 574 | blopes | 16 | private Date dataUltimaCompra; |
| 17 | private Date dataUltimaVenda; |
||
| 18 | private ProdutoPedidoCompraDTO produtoPedidoCompraDTO; |
||
| 19 | private FornecedorDTO fornecedorDTO; |
||
| 20 | |||
| 575 | blopes | 21 | private Integer quantidadeDiasParaComprar = 90; |
| 22 | |||
| 574 | blopes | 23 | // private RankingModeloDTO rankingModelo; |
| 24 | |||
| 25 | // private List<RankingComprasTransferenciasEstiloDTO> estilos; |
||
| 26 | // private List<RankingComprasTransferenciasAlertaDTO> alertas; |
||
| 27 | |||
| 28 | private Integer quantidadeAlertasPossiveis; |
||
| 29 | |||
| 30 | public AnaliseVendaProdutoDTO() { |
||
| 31 | // setEstilos(new ArrayList<RankingComprasTransferenciasEstiloDTO>()); |
||
| 32 | // setAlertas(new ArrayList<RankingComprasTransferenciasAlertaDTO>()); |
||
| 33 | setQuantidadeAlertasPossiveis(0); |
||
| 34 | } |
||
| 35 | |||
| 36 | public ProdutoDTO getProdutoDTO() { |
||
| 37 | return produtoDTO; |
||
| 38 | } |
||
| 39 | public void setProdutoDTO(ProdutoDTO produtoDTO) { |
||
| 40 | this.produtoDTO = produtoDTO; |
||
| 41 | } |
||
| 42 | |||
| 43 | public Integer getQuantidadeAlertasPossiveis() { |
||
| 44 | return quantidadeAlertasPossiveis; |
||
| 45 | } |
||
| 46 | public void setQuantidadeAlertasPossiveis(Integer quantidadeAlertasPossiveis) { |
||
| 47 | this.quantidadeAlertasPossiveis = quantidadeAlertasPossiveis; |
||
| 48 | } |
||
| 49 | |||
| 50 | public Integer getQuantidadeEstoque() { |
||
| 51 | return quantidadeEstoque; |
||
| 52 | } |
||
| 53 | public void setQuantidadeEstoque(Integer quantidadeEstoque) { |
||
| 54 | this.quantidadeEstoque = quantidadeEstoque; |
||
| 55 | } |
||
| 56 | |||
| 57 | public Integer getQuantidadeVendas() { |
||
| 58 | return quantidadeVendas; |
||
| 59 | } |
||
| 60 | public void setQuantidadeVendas(Integer quantidadeVendas) { |
||
| 61 | this.quantidadeVendas = quantidadeVendas; |
||
| 62 | } |
||
| 63 | |||
| 575 | blopes | 64 | public Integer getQuantidadeVendasAposCompra() { |
| 65 | return quantidadeVendasAposCompra; |
||
| 66 | } |
||
| 67 | public void setQuantidadeVendasAposCompra(Integer quantidadeVendasAposCompra) { |
||
| 68 | this.quantidadeVendasAposCompra = quantidadeVendasAposCompra; |
||
| 69 | } |
||
| 574 | blopes | 70 | public Date getDataUltimaCompra() { |
| 71 | return dataUltimaCompra; |
||
| 72 | } |
||
| 73 | public void setDataUltimaCompra(Date dataUltimaCompra) { |
||
| 74 | this.dataUltimaCompra = dataUltimaCompra; |
||
| 75 | } |
||
| 76 | |||
| 77 | public Date getDataUltimaVenda() { |
||
| 78 | return dataUltimaVenda; |
||
| 79 | } |
||
| 80 | public void setDataUltimaVenda(Date dataUltimaVenda) { |
||
| 81 | this.dataUltimaVenda = dataUltimaVenda; |
||
| 82 | } |
||
| 83 | |||
| 84 | public ProdutoPedidoCompraDTO getProdutoPedidoCompraDTO() { |
||
| 85 | return produtoPedidoCompraDTO; |
||
| 86 | } |
||
| 87 | public void setProdutoPedidoCompraDTO(ProdutoPedidoCompraDTO produtoPedidoCompraDTO) { |
||
| 88 | this.produtoPedidoCompraDTO = produtoPedidoCompraDTO; |
||
| 89 | } |
||
| 90 | |||
| 91 | public FornecedorDTO getFornecedorDTO() { |
||
| 92 | return fornecedorDTO; |
||
| 93 | } |
||
| 94 | public void setFornecedorDTO(FornecedorDTO fornecedorDTO) { |
||
| 95 | this.fornecedorDTO = fornecedorDTO; |
||
| 96 | } |
||
| 97 | |||
| 575 | blopes | 98 | public Integer getQuantidadeDiasParaComprar() { |
| 99 | return quantidadeDiasParaComprar; |
||
| 100 | } |
||
| 101 | public void setQuantidadeDiasParaComprar(Integer quantidadeDiasParaComprar) { |
||
| 102 | this.quantidadeDiasParaComprar = quantidadeDiasParaComprar; |
||
| 103 | } |
||
| 104 | |||
| 574 | blopes | 105 | /*********************************************/ |
| 106 | |||
| 575 | blopes | 107 | public Integer tempoDeEstoque() { |
| 108 | if (VerificadorUtil.naoEstaNulo(getQuantidadeVendasAposCompra())) { |
||
| 109 | return getQuantidadeVendasAposCompra()/QUANTIDADE_MESES_VENDAS_3; |
||
| 110 | } |
||
| 111 | return 0; |
||
| 112 | } |
||
| 113 | |||
| 114 | public Integer quantidadeParaComprar() { |
||
| 115 | |||
| 116 | return 0; |
||
| 117 | } |
||
| 118 | |||
| 574 | blopes | 119 | /* |
| 120 | public List<RankingComprasTransferenciasAlertaDTO> verificarAlertasLogistica(Double quantidadeMinimaParaTransferirOuComprar) { |
||
| 121 | List<RankingComprasTransferenciasAlertaDTO> alertas = new ArrayList<RankingComprasTransferenciasAlertaDTO>(); |
||
| 122 | |||
| 123 | for (RankingComprasTransferenciasEstiloDTO estilo : getEstilos()) { |
||
| 124 | Integer estoqueTotalMatriz = 0; |
||
| 125 | for (RankingComprasTransferenciasEstiloPorLojaDTO estiloPorLoja : estilo.getRankingsPorLoja()) { |
||
| 126 | if (estiloPorLoja.getLojaDTO().getSequencial().equals(ConstantesSEC.Loja.SEQUENCIAL_MATRIZ_ESTOQUE_9)) { |
||
| 127 | estoqueTotalMatriz = estiloPorLoja.getQuantidadeEstoqueGeral(); |
||
| 128 | break; |
||
| 129 | } |
||
| 130 | } |
||
| 131 | Integer estoqueMaiorLojaPrioridade = 0; |
||
| 132 | Integer quantidadeAlertasPossiveis = 0; |
||
| 133 | LojaDTO lojaMaiorPrioridade = null; |
||
| 134 | for (RankingComprasTransferenciasEstiloPorLojaDTO estiloPorLoja : estilo.getRankingsPorLoja()) { |
||
| 135 | if (!estiloPorLoja.getLojaDTO().getSequencial().equals(ConstantesSEC.Loja.SEQUENCIAL_MATRIZ_ESTOQUE_9)) { |
||
| 136 | |||
| 137 | estiloPorLoja.setQuantidadeMinimaTransferir(quantidadeMinimaParaTransferirOuComprar); |
||
| 138 | |||
| 139 | // VERIFICAR SE HÁ ESTOQUE NA MATRIZ E NÃO TEM EM ALGUMA LOJA |
||
| 140 | if (estoqueTotalMatriz > 0) { |
||
| 141 | if (estiloPorLoja.getQuantidadeEstoqueGeral() <= 0) { |
||
| 142 | adicionarAlertaLogistica(alertas, estiloPorLoja.getLojaDTO(), estilo.getEstilo(), TipoAlertaComprasTransferencias.SEM_ESTOQUE); |
||
| 143 | } else { |
||
| 144 | quantidadeAlertasPossiveis++; |
||
| 145 | } |
||
| 146 | } |
||
| 147 | |||
| 148 | // VERIFICAR SE TEM PARA TRANSFERIR |
||
| 149 | if (estiloPorLoja.quantidadeParaTransferirUnissex() > 0 || |
||
| 150 | estiloPorLoja.quantidadeParaTransferirMasculino() > 0 || |
||
| 151 | estiloPorLoja.quantidadeParaTransferirFeminino() > 0) { |
||
| 152 | adicionarAlertaLogistica(alertas, estiloPorLoja.getLojaDTO(), estilo.getEstilo(), TipoAlertaComprasTransferencias.TRANSFERIR); |
||
| 153 | } else { |
||
| 154 | quantidadeAlertasPossiveis++; |
||
| 155 | } |
||
| 156 | |||
| 157 | // VERIFICAR SE TEM ALGUMA LOJA DE MAIOR PRIORIDADE COM ESTOQUE MENOR |
||
| 158 | if (estoqueMaiorLojaPrioridade > 0) { |
||
| 159 | Integer estoqueTotalLoja = estiloPorLoja.getQuantidadeEstoqueGeral(); |
||
| 160 | if (estoqueMaiorLojaPrioridade < estoqueTotalLoja) { |
||
| 161 | adicionarAlertaLogistica(alertas, lojaMaiorPrioridade, estilo.getEstilo(), TipoAlertaComprasTransferencias.ESTOQUE_MENOR_PRIORIDADE); |
||
| 162 | } else { |
||
| 163 | quantidadeAlertasPossiveis++; |
||
| 164 | } |
||
| 165 | } |
||
| 166 | estoqueMaiorLojaPrioridade = estiloPorLoja.getQuantidadeEstoqueGeral(); |
||
| 167 | lojaMaiorPrioridade = estiloPorLoja.getLojaDTO(); |
||
| 168 | } |
||
| 169 | } |
||
| 170 | setQuantidadeAlertasPossiveis(quantidadeAlertasPossiveis); |
||
| 171 | } |
||
| 172 | return alertas; |
||
| 173 | } |
||
| 174 | |||
| 175 | private void adicionarAlertaLogistica(List<RankingComprasTransferenciasAlertaDTO> alertas, LojaDTO lojaDTO, TipoEstiloProduto estilo, TipoAlertaComprasTransferencias tipoAlerta) { |
||
| 176 | Boolean adicionarAlerta = true; |
||
| 177 | for (RankingComprasTransferenciasAlertaDTO alerta : alertas) { |
||
| 178 | if (alerta.getLoja().equals(lojaDTO) && alerta.getEstilo().equals(estilo)) { |
||
| 179 | adicionarAlerta = false; |
||
| 180 | } |
||
| 181 | } |
||
| 182 | if (adicionarAlerta) { |
||
| 183 | RankingComprasTransferenciasAlertaDTO alerta = new RankingComprasTransferenciasAlertaDTO(); |
||
| 184 | alerta.setLoja(lojaDTO); |
||
| 185 | alerta.setEstilo(estilo); |
||
| 186 | alerta.setTipoAlertaComprasTransferencias(tipoAlerta); |
||
| 187 | alertas.add(alerta); |
||
| 188 | } |
||
| 189 | } |
||
| 190 | |||
| 191 | public List<RankingComprasTransferenciasAlertaDTO> verificarAlertasCompras(Double quantidadeMinimaParaComprar) { |
||
| 192 | List<RankingComprasTransferenciasAlertaDTO> alertas = new ArrayList<RankingComprasTransferenciasAlertaDTO>(); |
||
| 193 | for (RankingComprasTransferenciasEstiloDTO estilo : getEstilos()) { |
||
| 194 | estilo.setQuantidadeMinimaComprar(quantidadeMinimaParaComprar); |
||
| 195 | if (estilo.quantidadeParaComprarUnissex() > 0) { |
||
| 196 | adicionarAlertaCompras(alertas, estilo.getEstilo(), TipoAlertaComprasTransferencias.COMPRAR, TipoGenero.UNISSEX); |
||
| 197 | } else { |
||
| 198 | quantidadeAlertasPossiveis++; |
||
| 199 | } |
||
| 200 | if (estilo.quantidadeParaComprarMasculino() > 0) { |
||
| 201 | adicionarAlertaCompras(alertas, estilo.getEstilo(), TipoAlertaComprasTransferencias.COMPRAR, TipoGenero.MASCULINO); |
||
| 202 | } else { |
||
| 203 | quantidadeAlertasPossiveis++; |
||
| 204 | } |
||
| 205 | if (estilo.quantidadeParaComprarFeminino() > 0) { |
||
| 206 | adicionarAlertaCompras(alertas, estilo.getEstilo(), TipoAlertaComprasTransferencias.COMPRAR, TipoGenero.FEMININO); |
||
| 207 | } else { |
||
| 208 | quantidadeAlertasPossiveis++; |
||
| 209 | } |
||
| 210 | } |
||
| 211 | return alertas; |
||
| 212 | } |
||
| 213 | |||
| 214 | private void adicionarAlertaCompras(List<RankingComprasTransferenciasAlertaDTO> alertas, TipoEstiloProduto estilo, TipoAlertaComprasTransferencias tipoAlerta, TipoGenero genero) { |
||
| 215 | Boolean adicionarAlerta = true; |
||
| 216 | for (RankingComprasTransferenciasAlertaDTO alerta : alertas) { |
||
| 217 | if (alerta.getEstilo().equals(estilo)) { |
||
| 218 | adicionarAlerta = false; |
||
| 219 | } |
||
| 220 | } |
||
| 221 | if (adicionarAlerta) { |
||
| 222 | RankingComprasTransferenciasAlertaDTO alerta = new RankingComprasTransferenciasAlertaDTO(); |
||
| 223 | alerta.setEstilo(estilo); |
||
| 224 | alerta.setTipoAlertaComprasTransferencias(tipoAlerta); |
||
| 225 | alerta.setGenero(genero); |
||
| 226 | alertas.add(alerta); |
||
| 227 | } |
||
| 228 | } |
||
| 229 | */ |
||
| 230 | } |