Rev 587 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 583 | blopes | 1 | package br.com.ec.domain.dto; |
| 2 | |||
| 3 | import java.util.ArrayList; |
||
| 4 | import java.util.List; |
||
| 5 | |||
| 6 | import br.com.ec.domain.model.tipos.TipoProduto; |
||
| 7 | |||
| 8 | public class AlertasComprasGeralDTO { |
||
| 9 | |||
| 10 | private TipoProduto tipoProduto; |
||
| 11 | private List<RankingProdutoDTO> alertasProdutosSemSubtipo; |
||
| 12 | private List<AlertasComprasGeralSubTipoDTO> alertasComprasGeralSubTipoDTO; |
||
| 13 | private Integer quantidadeAlertasPossiveis; |
||
| 584 | blopes | 14 | private Integer quantidadeAlertasPossiveisComSubtipo; |
| 587 | blopes | 15 | private Integer quantidadeAlertasCriticos; |
| 588 | blopes | 16 | private Integer quantidadeAlertasSemPedidoCompra; |
| 583 | blopes | 17 | |
| 18 | private Boolean verificado; |
||
| 19 | |||
| 20 | public AlertasComprasGeralDTO() { |
||
| 21 | setAlertasProdutosSemSubtipo(new ArrayList<RankingProdutoDTO>()); |
||
| 22 | setAlertasComprasGeralSubTipoDTO(new ArrayList<AlertasComprasGeralSubTipoDTO>()); |
||
| 23 | setQuantidadeAlertasPossiveis(0); |
||
| 584 | blopes | 24 | setQuantidadeAlertasPossiveisComSubtipo(0); |
| 587 | blopes | 25 | setQuantidadeAlertasCriticos(0); |
| 588 | blopes | 26 | setQuantidadeAlertasSemPedidoCompra(0); |
| 583 | blopes | 27 | setVerificado(false); |
| 28 | } |
||
| 29 | |||
| 30 | public TipoProduto getTipoProduto() { |
||
| 31 | return tipoProduto; |
||
| 32 | } |
||
| 33 | public void setTipoProduto(TipoProduto tipoProduto) { |
||
| 34 | this.tipoProduto = tipoProduto; |
||
| 35 | } |
||
| 36 | |||
| 37 | public List<RankingProdutoDTO> getAlertasProdutosSemSubtipo() { |
||
| 38 | return alertasProdutosSemSubtipo; |
||
| 39 | } |
||
| 40 | public void setAlertasProdutosSemSubtipo(List<RankingProdutoDTO> alertasProdutosSemSubtipo) { |
||
| 41 | this.alertasProdutosSemSubtipo = alertasProdutosSemSubtipo; |
||
| 42 | } |
||
| 43 | |||
| 44 | public List<AlertasComprasGeralSubTipoDTO> getAlertasComprasGeralSubTipoDTO() { |
||
| 45 | return alertasComprasGeralSubTipoDTO; |
||
| 46 | } |
||
| 47 | public void setAlertasComprasGeralSubTipoDTO(List<AlertasComprasGeralSubTipoDTO> alertasComprasGeralSubTipoDTO) { |
||
| 48 | this.alertasComprasGeralSubTipoDTO = alertasComprasGeralSubTipoDTO; |
||
| 49 | } |
||
| 50 | |||
| 51 | public Integer getQuantidadeAlertasPossiveis() { |
||
| 52 | return quantidadeAlertasPossiveis; |
||
| 53 | } |
||
| 54 | public void setQuantidadeAlertasPossiveis(Integer quantidadeAlertasPossiveis) { |
||
| 55 | this.quantidadeAlertasPossiveis = quantidadeAlertasPossiveis; |
||
| 56 | } |
||
| 57 | |||
| 584 | blopes | 58 | public Integer getQuantidadeAlertasPossiveisComSubtipo() { |
| 59 | return quantidadeAlertasPossiveisComSubtipo; |
||
| 60 | } |
||
| 61 | public void setQuantidadeAlertasPossiveisComSubtipo(Integer quantidadeAlertasPossiveisComSubtipo) { |
||
| 62 | this.quantidadeAlertasPossiveisComSubtipo = quantidadeAlertasPossiveisComSubtipo; |
||
| 63 | } |
||
| 64 | |||
| 587 | blopes | 65 | public Integer getQuantidadeAlertasCriticos() { |
| 66 | return quantidadeAlertasCriticos; |
||
| 67 | } |
||
| 68 | public void setQuantidadeAlertasCriticos(Integer quantidadeAlertasCriticos) { |
||
| 69 | this.quantidadeAlertasCriticos = quantidadeAlertasCriticos; |
||
| 70 | } |
||
| 71 | public void adicionarQuantidadeAlertasCriticos() { |
||
| 72 | quantidadeAlertasCriticos++; |
||
| 73 | } |
||
| 74 | |||
| 588 | blopes | 75 | public Integer getQuantidadeAlertasSemPedidoCompra() { |
| 76 | return quantidadeAlertasSemPedidoCompra; |
||
| 77 | } |
||
| 78 | public void setQuantidadeAlertasSemPedidoCompra(Integer quantidadeAlertasSemPedidoCompra) { |
||
| 79 | this.quantidadeAlertasSemPedidoCompra = quantidadeAlertasSemPedidoCompra; |
||
| 80 | } |
||
| 81 | public void adicionarQuantidadeAlertasSemPedidoCompra() { |
||
| 82 | quantidadeAlertasSemPedidoCompra++; |
||
| 83 | } |
||
| 84 | |||
| 583 | blopes | 85 | public Boolean getVerificado() { |
| 86 | return verificado; |
||
| 87 | } |
||
| 88 | public void setVerificado(Boolean verificado) { |
||
| 89 | this.verificado = verificado; |
||
| 90 | } |
||
| 91 | |||
| 92 | /******************************************************/ |
||
| 93 | |||
| 94 | public Integer getQuantidadeTotalAlertas() { |
||
| 95 | Integer quantidadeTotalAlertas = 0; |
||
| 96 | if (!getAlertasComprasGeralSubTipoDTO().isEmpty()) { |
||
| 97 | for (AlertasComprasGeralSubTipoDTO ranking : getAlertasComprasGeralSubTipoDTO()) { |
||
| 585 | blopes | 98 | quantidadeTotalAlertas += ranking.getRankingProdutosDTO().size(); |
| 583 | blopes | 99 | } |
| 100 | } |
||
| 585 | blopes | 101 | quantidadeTotalAlertas += getAlertasProdutosSemSubtipo().size(); |
| 583 | blopes | 102 | return quantidadeTotalAlertas; |
| 103 | } |
||
| 104 | |||
| 105 | public Integer getQuantidadeTotalAlertasPossiveis() { |
||
| 586 | blopes | 106 | return getQuantidadeAlertasPossiveis() + getQuantidadeAlertasPossiveisComSubtipo(); |
| 583 | blopes | 107 | } |
| 108 | |||
| 109 | public Double percentualAlertas() { |
||
| 110 | Double percentual = new Double(getQuantidadeTotalAlertas())/new Double(getQuantidadeTotalAlertasPossiveis()); |
||
| 111 | return 100 - (percentual * 100.0); |
||
| 112 | } |
||
| 113 | |||
| 114 | public String corPercentualAlerta() { |
||
| 115 | Double percentual = percentualAlertas(); |
||
| 116 | if (percentual > 90.0) { |
||
| 117 | return "green-haze"; |
||
| 118 | } |
||
| 119 | if (percentual > 50.0) { |
||
| 120 | return "orange"; |
||
| 121 | } |
||
| 122 | return "red"; |
||
| 123 | } |
||
| 124 | |||
| 125 | } |