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