Subversion Repositories Integrator Subversion

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
568 blopes 1
package br.com.ec.domain.dto;
2
 
3
import java.util.ArrayList;
4
import java.util.List;
5
 
6
public class AlertasLogisticaComprasDTO {
7
 
8
        private List<RankingComprasTransferenciasDTO> rankingsComprasTransferenciasDTO;
9
        private Integer quantidadeAlertasModelosPossiveis;
10
 
11
        public AlertasLogisticaComprasDTO() {
12
                setRankingsComprasTransferenciasDTO(new ArrayList<RankingComprasTransferenciasDTO>());
13
                setQuantidadeAlertasModelosPossiveis(0);
14
        }
15
 
16
        public List<RankingComprasTransferenciasDTO> getRankingsComprasTransferenciasDTO() {
17
                return rankingsComprasTransferenciasDTO;
18
        }
19
        public void setRankingsComprasTransferenciasDTO(List<RankingComprasTransferenciasDTO> rankingsComprasTransferenciasDTO) {
20
                this.rankingsComprasTransferenciasDTO = rankingsComprasTransferenciasDTO;
21
        }
22
 
23
        public Integer getQuantidadeAlertasModelosPossiveis() {
24
                return quantidadeAlertasModelosPossiveis;
25
        }
26
        public void setQuantidadeAlertasModelosPossiveis(Integer quantidadeAlertasModelosPossiveis) {
27
                this.quantidadeAlertasModelosPossiveis = quantidadeAlertasModelosPossiveis;
28
        }
29
 
30
        /******************************************************/
31
 
32
        public Integer getQuantidadeTotalAlertas() {
33
                Integer quantidadeTotalAlertas = 0;
34
                if (!getRankingsComprasTransferenciasDTO().isEmpty()) {
35
                        for (RankingComprasTransferenciasDTO ranking : getRankingsComprasTransferenciasDTO()) {
36
                                quantidadeTotalAlertas += ranking.getAlertas().size();
37
                        }
38
                }
39
                return quantidadeTotalAlertas;
40
        }
41
 
42
        public Integer getQuantidadeTotalAlertasPossiveis() {
43
                Integer quantidadeTotalAlertasPossiveis = 0;
44
                if (!getRankingsComprasTransferenciasDTO().isEmpty()) {
45
                        for (RankingComprasTransferenciasDTO ranking : getRankingsComprasTransferenciasDTO()) {
46
                                quantidadeTotalAlertasPossiveis += ranking.getQuantidadeAlertasPossiveis();
47
                        }
48
                }
49
                return quantidadeTotalAlertasPossiveis + getQuantidadeTotalAlertas();
50
        }
51
 
52
        public Double percentualAlertas() {
53
                Double percentual = new Double(getQuantidadeTotalAlertas())/new Double(getQuantidadeTotalAlertasPossiveis());
54
                return 100 - (percentual * 100.0);
55
        }
56
 
57
        public String corPercentualAlerta() {
58
                Double percentual = percentualAlertas();
59
                if (percentual > 90.0) {
60
                        return "green-haze";
61
                }
62
                if (percentual > 50.0) {
63
                        return "orange";
64
                }
65
                return "red";
66
        }
67
 
68
}