Subversion Repositories Integrator Subversion

Rev

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