Rev 586 | Go to most recent revision | 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; |
| 583 | blopes | 16 | |
| 17 | private Boolean verificado; |
||
| 18 | |||
| 19 | public AlertasComprasGeralDTO() { |
||
| 20 | setAlertasProdutosSemSubtipo(new ArrayList<RankingProdutoDTO>()); |
||
| 21 | setAlertasComprasGeralSubTipoDTO(new ArrayList<AlertasComprasGeralSubTipoDTO>()); |
||
| 22 | setQuantidadeAlertasPossiveis(0); |
||
| 584 | blopes | 23 | setQuantidadeAlertasPossiveisComSubtipo(0); |
| 587 | blopes | 24 | setQuantidadeAlertasCriticos(0); |
| 583 | blopes | 25 | setVerificado(false); |
| 26 | } |
||
| 27 | |||
| 28 | public TipoProduto getTipoProduto() { |
||
| 29 | return tipoProduto; |
||
| 30 | } |
||
| 31 | public void setTipoProduto(TipoProduto tipoProduto) { |
||
| 32 | this.tipoProduto = tipoProduto; |
||
| 33 | } |
||
| 34 | |||
| 35 | public List<RankingProdutoDTO> getAlertasProdutosSemSubtipo() { |
||
| 36 | return alertasProdutosSemSubtipo; |
||
| 37 | } |
||
| 38 | public void setAlertasProdutosSemSubtipo(List<RankingProdutoDTO> alertasProdutosSemSubtipo) { |
||
| 39 | this.alertasProdutosSemSubtipo = alertasProdutosSemSubtipo; |
||
| 40 | } |
||
| 41 | |||
| 42 | public List<AlertasComprasGeralSubTipoDTO> getAlertasComprasGeralSubTipoDTO() { |
||
| 43 | return alertasComprasGeralSubTipoDTO; |
||
| 44 | } |
||
| 45 | public void setAlertasComprasGeralSubTipoDTO(List<AlertasComprasGeralSubTipoDTO> alertasComprasGeralSubTipoDTO) { |
||
| 46 | this.alertasComprasGeralSubTipoDTO = alertasComprasGeralSubTipoDTO; |
||
| 47 | } |
||
| 48 | |||
| 49 | public Integer getQuantidadeAlertasPossiveis() { |
||
| 50 | return quantidadeAlertasPossiveis; |
||
| 51 | } |
||
| 52 | public void setQuantidadeAlertasPossiveis(Integer quantidadeAlertasPossiveis) { |
||
| 53 | this.quantidadeAlertasPossiveis = quantidadeAlertasPossiveis; |
||
| 54 | } |
||
| 55 | |||
| 584 | blopes | 56 | public Integer getQuantidadeAlertasPossiveisComSubtipo() { |
| 57 | return quantidadeAlertasPossiveisComSubtipo; |
||
| 58 | } |
||
| 59 | public void setQuantidadeAlertasPossiveisComSubtipo(Integer quantidadeAlertasPossiveisComSubtipo) { |
||
| 60 | this.quantidadeAlertasPossiveisComSubtipo = quantidadeAlertasPossiveisComSubtipo; |
||
| 61 | } |
||
| 62 | |||
| 587 | blopes | 63 | public Integer getQuantidadeAlertasCriticos() { |
| 64 | return quantidadeAlertasCriticos; |
||
| 65 | } |
||
| 66 | public void setQuantidadeAlertasCriticos(Integer quantidadeAlertasCriticos) { |
||
| 67 | this.quantidadeAlertasCriticos = quantidadeAlertasCriticos; |
||
| 68 | } |
||
| 69 | public void adicionarQuantidadeAlertasCriticos() { |
||
| 70 | quantidadeAlertasCriticos++; |
||
| 71 | } |
||
| 72 | |||
| 583 | blopes | 73 | public Boolean getVerificado() { |
| 74 | return verificado; |
||
| 75 | } |
||
| 76 | public void setVerificado(Boolean verificado) { |
||
| 77 | this.verificado = verificado; |
||
| 78 | } |
||
| 79 | |||
| 80 | /******************************************************/ |
||
| 81 | |||
| 82 | public Integer getQuantidadeTotalAlertas() { |
||
| 83 | Integer quantidadeTotalAlertas = 0; |
||
| 84 | if (!getAlertasComprasGeralSubTipoDTO().isEmpty()) { |
||
| 85 | for (AlertasComprasGeralSubTipoDTO ranking : getAlertasComprasGeralSubTipoDTO()) { |
||
| 585 | blopes | 86 | quantidadeTotalAlertas += ranking.getRankingProdutosDTO().size(); |
| 583 | blopes | 87 | } |
| 88 | } |
||
| 585 | blopes | 89 | quantidadeTotalAlertas += getAlertasProdutosSemSubtipo().size(); |
| 583 | blopes | 90 | return quantidadeTotalAlertas; |
| 91 | } |
||
| 92 | |||
| 93 | public Integer getQuantidadeTotalAlertasPossiveis() { |
||
| 586 | blopes | 94 | return getQuantidadeAlertasPossiveis() + getQuantidadeAlertasPossiveisComSubtipo(); |
| 583 | blopes | 95 | } |
| 96 | |||
| 97 | public Double percentualAlertas() { |
||
| 98 | Double percentual = new Double(getQuantidadeTotalAlertas())/new Double(getQuantidadeTotalAlertasPossiveis()); |
||
| 99 | return 100 - (percentual * 100.0); |
||
| 100 | } |
||
| 101 | |||
| 102 | public String corPercentualAlerta() { |
||
| 103 | Double percentual = percentualAlertas(); |
||
| 104 | if (percentual > 90.0) { |
||
| 105 | return "green-haze"; |
||
| 106 | } |
||
| 107 | if (percentual > 50.0) { |
||
| 108 | return "orange"; |
||
| 109 | } |
||
| 110 | return "red"; |
||
| 111 | } |
||
| 112 | |||
| 113 | } |