Subversion Repositories Integrator Subversion

Rev

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

Rev Author Line No. Line
106 espaco 1
package br.com.ec.controller.util;
2
 
3
import java.util.Calendar;
4
import java.util.Date;
5
import java.util.GregorianCalendar;
6
 
7
import javax.faces.bean.ManagedBean;
8
 
9
import org.springframework.context.annotation.Scope;
10
import org.springframework.stereotype.Component;
11
 
12
import br.com.ec.domain.shared.ConstantesSEC;
13
import br.com.ec.domain.shared.TipoCor;
14
import br.edu.cesmac.core.util.DataUtils;
15
import br.edu.cesmac.core.util.VerificadorUtil;
16
 
17
@Component
18
@ManagedBean
19
@Scope("view")
20
public class UtilBean {
21
 
22
        public static String padraoCodigoProduto(String codigoProduto) {
23
                try {
24
                        return !codigoProduto.isEmpty() ? String.format("%06d", new Long(codigoProduto)) : "";
25
                } catch (Exception e) {
26
                        return "";
27
                }
28
        }
29
 
30
        public static String statusContagem(Date dataVerificar) {
31
                if (dataVerificar != null) {
32
                        Integer quantidadeDias = DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), dataVerificar);
33
                        if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS) return "green";
34
                        if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_60_DIAS) return "orange";
35
                        if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_CHEIO_90_DIAS) return "black";
36
                }
37
                return "black";
38
        }
39
 
40
        public static String estiloVendas(Double valor) {
41
                if (VerificadorUtil.naoEstaNulo(valor)) {
42
                        if (valor > new Double(1999)) return TipoCor.VERDE_PADRAO.getDescricao();
43
                        if (valor > new Double(999)) return TipoCor.AZUL_PADRAO.getDescricao();
44
                        if (valor > new Double(499)) return "orange";
45
                }
46
                return "black";
47
        }
48
 
49
        public static String estiloValor(Double valor) {
50
                if (valor >= 0) return TipoCor.VERDE_PADRAO.getDescricao();
51
                if (valor < 0) return TipoCor.VERMELHO_PADRAO.getDescricao();
52
                return TipoCor.AZUL_PADRAO.getDescricao();
53
        }
54
 
55
        public static Boolean dataEstaVencida(Date data) {
56
                Date dataVerificar = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -1);
57
                return data.before(DataUtils.getDataComHorarioMaximo(dataVerificar));
58
        }
59
 
60
        public static String estiloVendasPorMeta(Double valorTotalVendasDoDia, Double valorMetaDiaria) {
61
                if (VerificadorUtil.naoEstaNulo(valorTotalVendasDoDia) && VerificadorUtil.naoEstaNulo(valorMetaDiaria)) {
62
                        if (valorTotalVendasDoDia >= valorMetaDiaria) return TipoCor.VERDE_PADRAO.getDescricao();
63
                        if (valorTotalVendasDoDia >= valorMetaDiaria * 0.8) return TipoCor.AZUL_PADRAO.getDescricao();
64
                        if (valorTotalVendasDoDia >= valorMetaDiaria * 0.5) return "orange";
65
                }
66
                return TipoCor.VERMELHO_PADRAO.getDescricao();
67
        }
68
 
69
        public static TipoCor corPorValor(Double valor) {
70
                if (valor >= 0) return TipoCor.VERDE_PADRAO;
71
                return TipoCor.VERMELHO_PADRAO;
72
        }
73
 
74
}