Subversion Repositories Integrator Subversion

Rev

Rev 587 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

package br.com.ec.domain.dto;

import java.util.ArrayList;
import java.util.List;

import br.com.ec.domain.model.tipos.TipoProduto;

public class AlertasComprasGeralDTO {

        private TipoProduto tipoProduto;
        private List<RankingProdutoDTO> alertasProdutosSemSubtipo;
        private List<AlertasComprasGeralSubTipoDTO> alertasComprasGeralSubTipoDTO;
        private Integer quantidadeAlertasPossiveis;
        private Integer quantidadeAlertasPossiveisComSubtipo;
        private Integer quantidadeAlertasCriticos;
        private Integer quantidadeAlertasSemPedidoCompra;
       
        private Boolean verificado;
       
        public AlertasComprasGeralDTO() {
                setAlertasProdutosSemSubtipo(new ArrayList<RankingProdutoDTO>());
                setAlertasComprasGeralSubTipoDTO(new ArrayList<AlertasComprasGeralSubTipoDTO>());
                setQuantidadeAlertasPossiveis(0);
                setQuantidadeAlertasPossiveisComSubtipo(0);
                setQuantidadeAlertasCriticos(0);
                setQuantidadeAlertasSemPedidoCompra(0);
                setVerificado(false);
        }
       
        public TipoProduto getTipoProduto() {
                return tipoProduto;
        }
        public void setTipoProduto(TipoProduto tipoProduto) {
                this.tipoProduto = tipoProduto;
        }
       
        public List<RankingProdutoDTO> getAlertasProdutosSemSubtipo() {
                return alertasProdutosSemSubtipo;
        }
        public void setAlertasProdutosSemSubtipo(List<RankingProdutoDTO> alertasProdutosSemSubtipo) {
                this.alertasProdutosSemSubtipo = alertasProdutosSemSubtipo;
        }
       
        public List<AlertasComprasGeralSubTipoDTO> getAlertasComprasGeralSubTipoDTO() {
                return alertasComprasGeralSubTipoDTO;
        }
        public void setAlertasComprasGeralSubTipoDTO(List<AlertasComprasGeralSubTipoDTO> alertasComprasGeralSubTipoDTO) {
                this.alertasComprasGeralSubTipoDTO = alertasComprasGeralSubTipoDTO;
        }
       
        public Integer getQuantidadeAlertasPossiveis() {
                return quantidadeAlertasPossiveis;
        }
        public void setQuantidadeAlertasPossiveis(Integer quantidadeAlertasPossiveis) {
                this.quantidadeAlertasPossiveis = quantidadeAlertasPossiveis;
        }
       
        public Integer getQuantidadeAlertasPossiveisComSubtipo() {
                return quantidadeAlertasPossiveisComSubtipo;
        }
        public void setQuantidadeAlertasPossiveisComSubtipo(Integer quantidadeAlertasPossiveisComSubtipo) {
                this.quantidadeAlertasPossiveisComSubtipo = quantidadeAlertasPossiveisComSubtipo;
        }
       
        public Integer getQuantidadeAlertasCriticos() {
                return quantidadeAlertasCriticos;
        }
        public void setQuantidadeAlertasCriticos(Integer quantidadeAlertasCriticos) {
                this.quantidadeAlertasCriticos = quantidadeAlertasCriticos;
        }
        public void adicionarQuantidadeAlertasCriticos() {
                quantidadeAlertasCriticos++;
        }
       
        public Integer getQuantidadeAlertasSemPedidoCompra() {
                return quantidadeAlertasSemPedidoCompra;
        }
        public void setQuantidadeAlertasSemPedidoCompra(Integer quantidadeAlertasSemPedidoCompra) {
                this.quantidadeAlertasSemPedidoCompra = quantidadeAlertasSemPedidoCompra;
        }
        public void adicionarQuantidadeAlertasSemPedidoCompra() {
                quantidadeAlertasSemPedidoCompra++;
        }
       
        public Boolean getVerificado() {
                return verificado;
        }
        public void setVerificado(Boolean verificado) {
                this.verificado = verificado;
        }
       
        /******************************************************/
       
        public Integer getQuantidadeTotalAlertas() {
                Integer quantidadeTotalAlertas = 0;
                if (!getAlertasComprasGeralSubTipoDTO().isEmpty()) {
                        for (AlertasComprasGeralSubTipoDTO ranking : getAlertasComprasGeralSubTipoDTO()) {
                                quantidadeTotalAlertas += ranking.getRankingProdutosDTO().size();
                        }
                }
                quantidadeTotalAlertas += getAlertasProdutosSemSubtipo().size();
                return quantidadeTotalAlertas;
        }
       
        public Integer getQuantidadeTotalAlertasPossiveis() {
                return getQuantidadeAlertasPossiveis() + getQuantidadeAlertasPossiveisComSubtipo();
        }
       
        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";
        }
       
}