Rev 259 | Details | Compare with Previous | 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; |
||
| 259 | espaco | 12 | import br.com.ec.domain.model.tipos.TipoCor; |
| 230 | espaco | 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 | public static String padraoCodigoProduto(String codigoProduto) { |
||
| 66 | try { |
||
| 67 | return !codigoProduto.isEmpty() ? String.format("%06d", new Long(codigoProduto)) : ""; |
||
| 68 | } catch (Exception e) { |
||
| 69 | return ""; |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 462 | blopes | 73 | /* |
| 74 | |||
| 230 | espaco | 75 | public static String statusContagem(Date dataVerificar, Date dataContagemSolicitada) { |
| 76 | if (dataVerificar != null) { |
||
| 77 | if (VerificadorUtil.naoEstaNulo(dataContagemSolicitada)) { |
||
| 78 | if (dataContagemSolicitada.before(dataVerificar)) { |
||
| 79 | return "green"; |
||
| 80 | } else { |
||
| 81 | Integer quantidadeDias = DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), dataVerificar); |
||
| 82 | if (quantidadeDias > ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_60_DIAS) return "pink"; |
||
| 83 | if (quantidadeDias > ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS) return "orange"; |
||
| 84 | } |
||
| 85 | } |
||
| 86 | } |
||
| 87 | return "black"; |
||
| 88 | } |
||
| 89 | |||
| 90 | public static String statusContagemAnterior(Date dataVerificar) { |
||
| 91 | if (dataVerificar != null) { |
||
| 92 | Integer quantidadeDias = DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), dataVerificar); |
||
| 93 | if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS) return "green"; |
||
| 94 | if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_60_DIAS) return "orange"; |
||
| 95 | if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_CHEIO_90_DIAS) return "black"; |
||
| 96 | } |
||
| 97 | return "black"; |
||
| 98 | } |
||
| 99 | |||
| 100 | public static String estiloVendas(Double valor) { |
||
| 101 | if (VerificadorUtil.naoEstaNulo(valor)) { |
||
| 102 | if (valor > new Double(1999)) return TipoCor.VERDE_PADRAO.getDescricao(); |
||
| 103 | if (valor > new Double(999)) return TipoCor.AZUL_PADRAO.getDescricao(); |
||
| 104 | if (valor > new Double(499)) return "orange"; |
||
| 105 | } |
||
| 106 | return "black"; |
||
| 107 | } |
||
| 108 | |||
| 109 | public static String estiloValor(Double valor) { |
||
| 110 | if (valor >= 0) return TipoCor.VERDE_PADRAO.getDescricao(); |
||
| 111 | if (valor < 0) return TipoCor.VERMELHO_PADRAO.getDescricao(); |
||
| 112 | return TipoCor.AZUL_PADRAO.getDescricao(); |
||
| 113 | } |
||
| 114 | |||
| 115 | public static Boolean dataEstaVencida(Date data) { |
||
| 116 | Date dataVerificar = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -1); |
||
| 117 | return data.before(DataUtils.getDataComHorarioMaximo(dataVerificar)); |
||
| 118 | } |
||
| 119 | |||
| 120 | public static String estiloVendasPorMeta(Double valorTotalVendasDoDia, Double valorMetaDiaria) { |
||
| 121 | if (VerificadorUtil.naoEstaNulo(valorTotalVendasDoDia) && VerificadorUtil.naoEstaNulo(valorMetaDiaria)) { |
||
| 122 | if (valorTotalVendasDoDia >= valorMetaDiaria) return TipoCor.VERDE_PADRAO.getDescricao(); |
||
| 123 | if (valorTotalVendasDoDia >= valorMetaDiaria * 0.8) return TipoCor.AZUL_PADRAO.getDescricao(); |
||
| 124 | if (valorTotalVendasDoDia >= valorMetaDiaria * 0.5) return "orange"; |
||
| 125 | } |
||
| 126 | return TipoCor.VERMELHO_PADRAO.getDescricao(); |
||
| 127 | } |
||
| 128 | |||
| 129 | public static TipoCor corPorValor(Double valor) { |
||
| 130 | if (valor >= 0) return TipoCor.VERDE_PADRAO; |
||
| 131 | return TipoCor.VERMELHO_PADRAO; |
||
| 132 | } |
||
| 133 | */ |
||
| 134 | |||
| 135 | } |