Rev 568 | Details | Compare with Previous | 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 | |||
| 587 | blopes | 6 | import br.com.ec.domain.model.tipos.TipoAlertaComprasTransferencias; |
| 7 | |||
| 568 | blopes | 8 | public class AlertasLogisticaComprasDTO { |
| 9 | |||
| 10 | private List<RankingComprasTransferenciasDTO> rankingsComprasTransferenciasDTO; |
||
| 11 | private Integer quantidadeAlertasModelosPossiveis; |
||
| 12 | |||
| 13 | public AlertasLogisticaComprasDTO() { |
||
| 14 | setRankingsComprasTransferenciasDTO(new ArrayList<RankingComprasTransferenciasDTO>()); |
||
| 15 | setQuantidadeAlertasModelosPossiveis(0); |
||
| 16 | } |
||
| 17 | |||
| 18 | public List<RankingComprasTransferenciasDTO> getRankingsComprasTransferenciasDTO() { |
||
| 19 | return rankingsComprasTransferenciasDTO; |
||
| 20 | } |
||
| 21 | public void setRankingsComprasTransferenciasDTO(List<RankingComprasTransferenciasDTO> rankingsComprasTransferenciasDTO) { |
||
| 22 | this.rankingsComprasTransferenciasDTO = rankingsComprasTransferenciasDTO; |
||
| 23 | } |
||
| 24 | |||
| 25 | public Integer getQuantidadeAlertasModelosPossiveis() { |
||
| 26 | return quantidadeAlertasModelosPossiveis; |
||
| 27 | } |
||
| 28 | public void setQuantidadeAlertasModelosPossiveis(Integer quantidadeAlertasModelosPossiveis) { |
||
| 29 | this.quantidadeAlertasModelosPossiveis = quantidadeAlertasModelosPossiveis; |
||
| 30 | } |
||
| 31 | |||
| 32 | /******************************************************/ |
||
| 33 | |||
| 34 | public Integer getQuantidadeTotalAlertas() { |
||
| 35 | Integer quantidadeTotalAlertas = 0; |
||
| 36 | if (!getRankingsComprasTransferenciasDTO().isEmpty()) { |
||
| 37 | for (RankingComprasTransferenciasDTO ranking : getRankingsComprasTransferenciasDTO()) { |
||
| 38 | quantidadeTotalAlertas += ranking.getAlertas().size(); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | return quantidadeTotalAlertas; |
||
| 42 | } |
||
| 43 | |||
| 44 | public Integer getQuantidadeTotalAlertasPossiveis() { |
||
| 45 | Integer quantidadeTotalAlertasPossiveis = 0; |
||
| 46 | if (!getRankingsComprasTransferenciasDTO().isEmpty()) { |
||
| 47 | for (RankingComprasTransferenciasDTO ranking : getRankingsComprasTransferenciasDTO()) { |
||
| 48 | quantidadeTotalAlertasPossiveis += ranking.getQuantidadeAlertasPossiveis(); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | return quantidadeTotalAlertasPossiveis + getQuantidadeTotalAlertas(); |
||
| 52 | } |
||
| 53 | |||
| 587 | blopes | 54 | public Integer getQuantidadeTotalAlertasCriticos() { |
| 55 | Integer quantidadeTotalAlertas = 0; |
||
| 56 | if (!getRankingsComprasTransferenciasDTO().isEmpty()) { |
||
| 57 | for (RankingComprasTransferenciasDTO ranking : getRankingsComprasTransferenciasDTO()) { |
||
| 58 | for (RankingComprasTransferenciasAlertaDTO alerta : ranking.getAlertas()) { |
||
| 59 | if (alerta.getTipoAlertaComprasTransferencias().getValor().equals(TipoAlertaComprasTransferencias.TRANSFERIR.getValor())) { |
||
| 60 | quantidadeTotalAlertas++; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | return quantidadeTotalAlertas; |
||
| 66 | } |
||
| 67 | |||
| 568 | blopes | 68 | public Double percentualAlertas() { |
| 69 | Double percentual = new Double(getQuantidadeTotalAlertas())/new Double(getQuantidadeTotalAlertasPossiveis()); |
||
| 70 | return 100 - (percentual * 100.0); |
||
| 71 | } |
||
| 72 | |||
| 73 | public String corPercentualAlerta() { |
||
| 74 | Double percentual = percentualAlertas(); |
||
| 75 | if (percentual > 90.0) { |
||
| 76 | return "green-haze"; |
||
| 77 | } |
||
| 78 | if (percentual > 50.0) { |
||
| 79 | return "orange"; |
||
| 80 | } |
||
| 81 | return "red"; |
||
| 82 | } |
||
| 83 | |||
| 84 | } |