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