Rev 195 | 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 | |||
| 221 | espaco | 28 | public static String statusContagem(Date dataVerificar, Date dataContagemSolicitada) { |
| 106 | espaco | 29 | if (dataVerificar != null) { |
| 221 | espaco | 30 | if (VerificadorUtil.naoEstaNulo(dataContagemSolicitada)) { |
| 31 | if (dataContagemSolicitada.before(dataVerificar)) { |
||
| 32 | return "green"; |
||
| 33 | } else { |
||
| 34 | Integer quantidadeDias = DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), dataVerificar); |
||
| 35 | if (quantidadeDias > ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_60_DIAS) return "pink"; |
||
| 36 | if (quantidadeDias > ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS) return "orange"; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | } |
||
| 40 | return "black"; |
||
| 41 | } |
||
| 42 | |||
| 43 | public static String statusContagemAnterior(Date dataVerificar) { |
||
| 44 | if (dataVerificar != null) { |
||
| 106 | espaco | 45 | Integer quantidadeDias = DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), dataVerificar); |
| 46 | if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_AMARELO_30_DIAS) return "green"; |
||
| 47 | if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_60_DIAS) return "orange"; |
||
| 48 | if (quantidadeDias <= ConstantesSEC.StatusContagem.CONTAGEM_VERMELHO_CHEIO_90_DIAS) return "black"; |
||
| 49 | } |
||
| 50 | return "black"; |
||
| 51 | } |
||
| 52 | |||
| 53 | public static String estiloVendas(Double valor) { |
||
| 54 | if (VerificadorUtil.naoEstaNulo(valor)) { |
||
| 55 | if (valor > new Double(1999)) return TipoCor.VERDE_PADRAO.getDescricao(); |
||
| 56 | if (valor > new Double(999)) return TipoCor.AZUL_PADRAO.getDescricao(); |
||
| 57 | if (valor > new Double(499)) return "orange"; |
||
| 58 | } |
||
| 59 | return "black"; |
||
| 60 | } |
||
| 61 | |||
| 62 | public static String estiloValor(Double valor) { |
||
| 63 | if (valor >= 0) return TipoCor.VERDE_PADRAO.getDescricao(); |
||
| 64 | if (valor < 0) return TipoCor.VERMELHO_PADRAO.getDescricao(); |
||
| 65 | return TipoCor.AZUL_PADRAO.getDescricao(); |
||
| 66 | } |
||
| 67 | |||
| 68 | public static Boolean dataEstaVencida(Date data) { |
||
| 69 | Date dataVerificar = DataUtils.acrescentarDias(DataUtils.getDataAtual(), -1); |
||
| 70 | return data.before(DataUtils.getDataComHorarioMaximo(dataVerificar)); |
||
| 71 | } |
||
| 72 | |||
| 73 | public static String estiloVendasPorMeta(Double valorTotalVendasDoDia, Double valorMetaDiaria) { |
||
| 74 | if (VerificadorUtil.naoEstaNulo(valorTotalVendasDoDia) && VerificadorUtil.naoEstaNulo(valorMetaDiaria)) { |
||
| 75 | if (valorTotalVendasDoDia >= valorMetaDiaria) return TipoCor.VERDE_PADRAO.getDescricao(); |
||
| 76 | if (valorTotalVendasDoDia >= valorMetaDiaria * 0.8) return TipoCor.AZUL_PADRAO.getDescricao(); |
||
| 77 | if (valorTotalVendasDoDia >= valorMetaDiaria * 0.5) return "orange"; |
||
| 78 | } |
||
| 79 | return TipoCor.VERMELHO_PADRAO.getDescricao(); |
||
| 80 | } |
||
| 81 | |||
| 82 | public static TipoCor corPorValor(Double valor) { |
||
| 83 | if (valor >= 0) return TipoCor.VERDE_PADRAO; |
||
| 84 | return TipoCor.VERMELHO_PADRAO; |
||
| 85 | } |
||
| 86 | |||
| 87 | } |