Subversion Repositories Integrator Subversion

Rev

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

Rev Author Line No. Line
230 espaco 1
package br.com.ec.domain.shared;
2
 
3
import java.util.Date;
4
 
5
import javax.faces.bean.ManagedBean;
6
 
7
import org.springframework.context.annotation.Scope;
8
import org.springframework.stereotype.Component;
9
 
10
import br.com.ec.core.util.DataUtils;
11
import br.com.ec.core.util.VerificadorUtil;
12
import br.com.ec.domain.modal.tipos.TipoCor;
13
 
14
@Component
15
@ManagedBean
16
@Scope("view")
17
public class UtilBean {
18
 
19
        public static String corSobreMetaCorrente(Double percentualRealizadoNoMesAtual) {
20
                Double percentualPercorridoNoMes = percentualPercorridoNoMes();
21
                if (VerificadorUtil.naoEstaNulo(percentualRealizadoNoMesAtual) && VerificadorUtil.naoEstaNulo(percentualPercorridoNoMes)) {
22
                        Double diferenca = percentualRealizadoNoMesAtual - (percentualPercorridoNoMes/100);
23
                        Double diferencaSetentaCinco = percentualPercorridoNoMes * 25 / 100;
24
                        if (diferenca > 0.24) {
25
                                return TipoCor.AZUL_PADRAO.getValor();
26
                        } else if (diferenca > 0) {
27
                                return TipoCor.VERDE_PADRAO.getValor();
28
                        } else if (diferenca > (diferencaSetentaCinco * -1 / 100)) {
29
                                return TipoCor.LARANJA_PADRAO.getValor();
30
                        } else {
31
                                return TipoCor.VERMELHO.getValor();
32
                        }
33
                }
34
                return TipoCor.PRETO.getValor();
35
        }
36
 
37
        public static String corSobreVendasPorMeta(Double valorTotalVendasDoDia, Double valorMetaDiaria) {
38
                if (VerificadorUtil.naoEstaNulo(valorTotalVendasDoDia) && VerificadorUtil.naoEstaNulo(valorMetaDiaria)) {
39
                        if (valorTotalVendasDoDia >= valorMetaDiaria) return TipoCor.VERDE_PADRAO.getDescricao();
40
                        if (valorTotalVendasDoDia >= valorMetaDiaria * 0.8) return TipoCor.AZUL_PADRAO.getDescricao();
41
                        if (valorTotalVendasDoDia >= valorMetaDiaria * 0.5) return TipoCor.LARANJA_PADRAO.getDescricao();
42
                }
43
                return TipoCor.VERMELHO_PADRAO.getDescricao();
44
        }
45
 
46
        public static String setaSobreMetaCorrente(Double percentualRealizadoNoMesAtual) {
47
                Double percentualPercorridoNoMes = percentualPercorridoNoMes();
48
                if (VerificadorUtil.naoEstaNulo(percentualRealizadoNoMesAtual) && VerificadorUtil.naoEstaNulo(percentualPercorridoNoMes)) {
49
                        Double diferenca = percentualRealizadoNoMesAtual - (percentualPercorridoNoMes/100);
50
                        if (diferenca > 0) {
51
                                return "pi pi-arrow-up";
52
                        } else {
53
                                return "pi pi-arrow-down";
54
                        }
55
                }
56
                return "pi pi-minus";
57
        }
58
 
59
        public static Double percentualPercorridoNoMes() {
60
                Integer ultimoDiaDoMes = DataUtils.getUltimoDiaDoMesAtual().getDate();
61
                Integer diaAtual = DataUtils.getDataAtual().getDate();
62
                return new Double(100*diaAtual/ultimoDiaDoMes);
63
        }
64
 
65
 
66
        /*
67
 
68
        public static String padraoCodigoProduto(String codigoProduto) {
69
                try {
70
                        return !codigoProduto.isEmpty() ? String.format("%06d", new Long(codigoProduto)) : "";
71
                } catch (Exception e) {
72
                        return "";
73
                }
74
        }
75
 
76
        public static String statusContagem(Date dataVerificar, Date dataContagemSolicitada) {
77
                if (dataVerificar != null) {
78
                        if (VerificadorUtil.naoEstaNulo(dataContagemSolicitada)) {
79
                                if (dataContagemSolicitada.before(dataVerificar)) {
80
                                        return "green";
81
                                } else {
82
                                        Integer quantidadeDias = DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), dataVerificar);
83
                                        if (quantidadeDias > ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_60_DIAS) return "pink";
84
                                        if (quantidadeDias > ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS) return "orange";
85
                                }
86
                        }
87
                }
88
                return "black";
89
        }
90
 
91
        public static String statusContagemAnterior(Date dataVerificar) {
92
                if (dataVerificar != null) {
93
                        Integer quantidadeDias = DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), dataVerificar);
94
                        if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS) return "green";
95
                        if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_60_DIAS) return "orange";
96
                        if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_CHEIO_90_DIAS) return "black";
97
                }
98
                return "black";
99
        }
100
 
101
        public static String estiloVendas(Double valor) {
102
                if (VerificadorUtil.naoEstaNulo(valor)) {
103
                        if (valor > new Double(1999)) return TipoCor.VERDE_PADRAO.getDescricao();
104
                        if (valor > new Double(999)) return TipoCor.AZUL_PADRAO.getDescricao();
105
                        if (valor > new Double(499)) return "orange";
106
                }
107
                return "black";
108
        }
109
 
110
        public static String estiloValor(Double valor) {
111
                if (valor >= 0) return TipoCor.VERDE_PADRAO.getDescricao();
112
                if (valor < 0) return TipoCor.VERMELHO_PADRAO.getDescricao();
113
                return TipoCor.AZUL_PADRAO.getDescricao();
114
        }
115
 
116
        public static Boolean dataEstaVencida(Date data) {
117
                Date dataVerificar = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -1);
118
                return data.before(DataUtils.getDataComHorarioMaximo(dataVerificar));
119
        }
120
 
121
        public static String estiloVendasPorMeta(Double valorTotalVendasDoDia, Double valorMetaDiaria) {
122
                if (VerificadorUtil.naoEstaNulo(valorTotalVendasDoDia) && VerificadorUtil.naoEstaNulo(valorMetaDiaria)) {
123
                        if (valorTotalVendasDoDia >= valorMetaDiaria) return TipoCor.VERDE_PADRAO.getDescricao();
124
                        if (valorTotalVendasDoDia >= valorMetaDiaria * 0.8) return TipoCor.AZUL_PADRAO.getDescricao();
125
                        if (valorTotalVendasDoDia >= valorMetaDiaria * 0.5) return "orange";
126
                }
127
                return TipoCor.VERMELHO_PADRAO.getDescricao();
128
        }
129
 
130
        public static TipoCor corPorValor(Double valor) {
131
                if (valor >= 0) return TipoCor.VERDE_PADRAO;
132
                return TipoCor.VERMELHO_PADRAO;
133
        }
134
        */
135
 
136
}