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