package br.com.ec.domain.dto;
import java.util.ArrayList;
import java.util.List;
import br.com.ec.domain.model.tipos.TipoAlertaComprasTransferencias;
public class AlertasLogisticaComprasDTO
{
private List<RankingComprasTransferenciasDTO
> rankingsComprasTransferenciasDTO
;
private Integer quantidadeAlertasModelosPossiveis
;
public AlertasLogisticaComprasDTO
() {
setRankingsComprasTransferenciasDTO
(new ArrayList<RankingComprasTransferenciasDTO
>());
setQuantidadeAlertasModelosPossiveis
(0);
}
public List<RankingComprasTransferenciasDTO
> getRankingsComprasTransferenciasDTO
() {
return rankingsComprasTransferenciasDTO
;
}
public void setRankingsComprasTransferenciasDTO
(List<RankingComprasTransferenciasDTO
> rankingsComprasTransferenciasDTO
) {
this.
rankingsComprasTransferenciasDTO = rankingsComprasTransferenciasDTO
;
}
public Integer getQuantidadeAlertasModelosPossiveis
() {
return quantidadeAlertasModelosPossiveis
;
}
public void setQuantidadeAlertasModelosPossiveis
(Integer quantidadeAlertasModelosPossiveis
) {
this.
quantidadeAlertasModelosPossiveis = quantidadeAlertasModelosPossiveis
;
}
/******************************************************/
public Integer getQuantidadeTotalAlertas
() {
Integer quantidadeTotalAlertas =
0;
if (!getRankingsComprasTransferenciasDTO
().
isEmpty()) {
for (RankingComprasTransferenciasDTO ranking : getRankingsComprasTransferenciasDTO
()) {
quantidadeTotalAlertas += ranking.
getAlertas().
size();
}
}
return quantidadeTotalAlertas
;
}
public Integer getQuantidadeTotalAlertasPossiveis
() {
Integer quantidadeTotalAlertasPossiveis =
0;
if (!getRankingsComprasTransferenciasDTO
().
isEmpty()) {
for (RankingComprasTransferenciasDTO ranking : getRankingsComprasTransferenciasDTO
()) {
quantidadeTotalAlertasPossiveis += ranking.
getQuantidadeAlertasPossiveis();
}
}
return quantidadeTotalAlertasPossiveis + getQuantidadeTotalAlertas
();
}
public Integer getQuantidadeTotalAlertasCriticos
() {
Integer quantidadeTotalAlertas =
0;
if (!getRankingsComprasTransferenciasDTO
().
isEmpty()) {
for (RankingComprasTransferenciasDTO ranking : getRankingsComprasTransferenciasDTO
()) {
for (RankingComprasTransferenciasAlertaDTO alerta : ranking.
getAlertas()) {
if (alerta.
getTipoAlertaComprasTransferencias().
getValor().
equals(TipoAlertaComprasTransferencias.
TRANSFERIR.
getValor())) {
quantidadeTotalAlertas++
;
}
}
}
}
return quantidadeTotalAlertas
;
}
public Double percentualAlertas
() {
Double percentual =
new Double(getQuantidadeTotalAlertas
())/
new Double(getQuantidadeTotalAlertasPossiveis
());
return 100 -
(percentual
* 100.0);
}
public String corPercentualAlerta
() {
Double percentual = percentualAlertas
();
if (percentual
> 90.0) {
return "green-haze";
}
if (percentual
> 50.0) {
return "orange";
}
return "red";
}
}