Rev 627 | Rev 629 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 625 | blopes | 1 | package br.com.ec.controller; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.ArrayList; |
||
| 5 | import java.util.List; |
||
| 6 | |||
| 7 | import javax.inject.Inject; |
||
| 8 | import javax.inject.Named; |
||
| 9 | |||
| 628 | blopes | 10 | import org.apache.commons.httpclient.util.DateUtil; |
| 11 | import org.apache.commons.lang.time.DateUtils; |
||
| 625 | blopes | 12 | import org.springframework.context.annotation.Scope; |
| 13 | |||
| 14 | import br.com.ec.core.generic.GenericService; |
||
| 628 | blopes | 15 | import br.com.ec.core.util.DataUtils; |
| 625 | blopes | 16 | import br.com.ec.core.util.VerificadorUtil; |
| 17 | import br.com.ec.domain.dto.ComercialPosVendaDTO; |
||
| 18 | import br.com.ec.domain.model.NpsPosVenda; |
||
| 19 | import br.com.ec.domain.model.PosVenda; |
||
| 20 | import br.com.ec.domain.model.tipos.TipoNpsPosVenda; |
||
| 21 | import br.com.ec.domain.model.tipos.TipoPeriodoConsulta; |
||
| 628 | blopes | 22 | import br.com.ec.domain.service.NpsPosVendaService; |
| 625 | blopes | 23 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 24 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 25 | import br.com.ec.web.generic.AbstractBean; |
||
| 26 | |||
| 27 | @Named |
||
| 28 | @Scope("view") |
||
| 29 | public class NpsPosVendaBean extends AbstractBean<ComercialPosVendaDTO> implements Serializable { |
||
| 30 | |||
| 31 | private static final long serialVersionUID = 1L; |
||
| 32 | |||
| 628 | blopes | 33 | private NpsPosVendaService npsPosVendaService; |
| 625 | blopes | 34 | |
| 35 | private NpsPosVenda npsPosVendaSelecionado; |
||
| 36 | |||
| 37 | public static class NpsItem { |
||
| 38 | private final Integer nota; |
||
| 39 | private final String icone; |
||
| 40 | private final String estrelas; |
||
| 41 | |||
| 42 | public NpsItem(Integer nota, String icone, String estrelas) { |
||
| 43 | this.nota = nota; |
||
| 44 | this.icone = icone; |
||
| 45 | this.estrelas = estrelas; |
||
| 46 | } |
||
| 47 | |||
| 48 | public Integer getNota() { return nota; } |
||
| 49 | public String getIcone() { return icone; } |
||
| 50 | public String getEstrelas() { return estrelas; } |
||
| 51 | } |
||
| 52 | |||
| 53 | @Inject |
||
| 628 | blopes | 54 | public NpsPosVendaBean(NpsPosVendaService npsPosVendaService) { |
| 55 | this.npsPosVendaService = npsPosVendaService; |
||
| 625 | blopes | 56 | } |
| 57 | |||
| 58 | @Override |
||
| 59 | public GenericService<ComercialPosVendaDTO> getService() { |
||
| 60 | return null; |
||
| 61 | } |
||
| 62 | |||
| 63 | @Override |
||
| 64 | public ComercialPosVendaDTO getId() { |
||
| 65 | return null; |
||
| 66 | } |
||
| 67 | |||
| 68 | @Override |
||
| 69 | public void preCarregamento() { |
||
| 70 | limparEntidade(); |
||
| 71 | } |
||
| 72 | |||
| 73 | @Override |
||
| 74 | public void limparEntidade() { |
||
| 75 | } |
||
| 76 | |||
| 77 | public List<NpsItem> getRostosNps() { |
||
| 78 | List<NpsItem> lista = new ArrayList<>(); |
||
| 79 | for (int i = 1; i <= 5; i++) { |
||
| 627 | blopes | 80 | String icone = "rosto-" + i + ".png"; // Ex: emoji0.png até emoji10.png |
| 625 | blopes | 81 | String estrelas = new String(new char[5]).replace("\0", "⭐");//"⭐".repeat(Math.max(0, i / 2)); // Converte nota para estrelas visuais |
| 82 | lista.add(new NpsItem(new Integer(i), icone, estrelas)); |
||
| 83 | } |
||
| 84 | return lista; |
||
| 85 | } |
||
| 86 | |||
| 87 | /**************************************************/ |
||
| 88 | |||
| 89 | public TipoPeriodoConsulta[] getTiposPeriodoConsulta() { |
||
| 90 | return TipoPeriodoConsulta.values(); |
||
| 91 | } |
||
| 92 | |||
| 93 | /**************************************************/ |
||
| 94 | |||
| 95 | public NpsPosVenda getNpsPosVendaSelecionado() { |
||
| 96 | if (VerificadorUtil.estaNulo(npsPosVendaSelecionado)) { |
||
| 97 | if (VerificadorUtil.naoEstaNulo(getParametro("sq"))) { |
||
| 98 | npsPosVendaSelecionado = new NpsPosVenda(); |
||
| 99 | npsPosVendaSelecionado.setPosVenda(new PosVenda(new Long(getParametro("sq").toString()))); |
||
| 100 | npsPosVendaSelecionado.setObservacao(""); |
||
| 101 | npsPosVendaSelecionado.setTipoNps(TipoNpsPosVenda.ATENDIMENTO_A.getValor()); |
||
| 102 | } |
||
| 103 | } |
||
| 104 | return npsPosVendaSelecionado; |
||
| 105 | } |
||
| 106 | public void setNpsPosVendaSelecionado(NpsPosVenda npsPosVendaSelecionado) { |
||
| 107 | this.npsPosVendaSelecionado = npsPosVendaSelecionado; |
||
| 108 | } |
||
| 109 | |||
| 628 | blopes | 110 | public void selecionarNota() { |
| 111 | if (VerificadorUtil.naoEstaNulo(getNpsPosVendaSelecionado())) { |
||
| 112 | System.out.println(getNpsPosVendaSelecionado().getNota()); |
||
| 113 | } else { |
||
| 114 | System.out.println("SEM NOTA!"); |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 625 | blopes | 118 | public void efetivarNps() { |
| 119 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 120 | public void execute() { |
||
| 628 | blopes | 121 | getNpsPosVendaSelecionado().setDataFinalizacao(DataUtils.getDataAtual()); |
| 122 | npsPosVendaService.alterar(getNpsPosVendaSelecionado()); |
||
| 625 | blopes | 123 | } |
| 124 | }); |
||
| 125 | } |
||
| 126 | |||
| 127 | } |