Subversion Repositories Integrator Subversion

Rev

Rev 629 | Rev 631 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
623 blopes 1
package br.com.ec.controller;
2
 
3
import java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.Date;
6
import java.util.List;
7
 
8
import javax.inject.Inject;
9
import javax.inject.Named;
10
 
11
import org.springframework.context.annotation.Scope;
12
 
13
import br.com.ec.core.generic.GenericService;
14
import br.com.ec.core.util.DataUtils;
15
import br.com.ec.domain.dto.ClienteDTO;
16
import br.com.ec.domain.dto.ComercialPosVendaDTO;
17
import br.com.ec.domain.dto.PosVendaDTO;
18
import br.com.ec.domain.dto.VendaDTO;
625 blopes 19
import br.com.ec.domain.model.PosVenda;
629 blopes 20
import br.com.ec.domain.model.tipos.TipoNpsPosVenda;
623 blopes 21
import br.com.ec.domain.model.tipos.TipoPeriodoConsulta;
624 blopes 22
import br.com.ec.domain.service.LancamentoService;
629 blopes 23
import br.com.ec.domain.service.NpsPosVendaService;
623 blopes 24
import br.com.ec.domain.service.PosVendaService;
25
import br.com.ec.domain.service.TransferenciaService;
26
import br.com.ec.web.exception.VerificadorLancamentoException;
27
import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean;
28
import br.com.ec.web.generic.AbstractBean;
625 blopes 29
import br.com.ec.web.message.LancadorMensagem;
623 blopes 30
 
31
@Named
32
@Scope("view")
33
public class PosVendaBean extends AbstractBean<ComercialPosVendaDTO> implements Serializable {
34
 
35
        private static final long serialVersionUID = 1L;
36
 
37
        private PosVendaService posVendaService;
629 blopes 38
        private NpsPosVendaService npsPosVendaService;
624 blopes 39
        private LancamentoService lancamentoService;
623 blopes 40
 
41
        private PosVendaDTO posVendaSelecionado;
42
 
625 blopes 43
        public static class NpsItem {
44
        private final int nota;
45
        private final String icone;
46
        private final String estrelas;
47
 
48
        public NpsItem(int nota, String icone, String estrelas) {
49
            this.nota = nota;
50
            this.icone = icone;
51
            this.estrelas = estrelas;
52
        }
53
 
54
        public int getNota() { return nota; }
55
        public String getIcone() { return icone; }
56
        public String getEstrelas() { return estrelas; }
57
    }
58
 
623 blopes 59
        @Inject
629 blopes 60
        public PosVendaBean(PosVendaService posVendaService, NpsPosVendaService npsPosVendaService, LancamentoService lancamentoService) {
623 blopes 61
                this.posVendaService = posVendaService;
624 blopes 62
                this.lancamentoService = lancamentoService;
629 blopes 63
                this.npsPosVendaService = npsPosVendaService;
623 blopes 64
        }
65
 
66
        @Override
67
        public GenericService<ComercialPosVendaDTO> getService() {
68
                return null;
69
        }
70
 
71
        @Override
72
        public ComercialPosVendaDTO getId() {
73
                return null;
74
        }
75
 
76
        @Override
77
        public void preCarregamento() {
78
                limparEntidade();
79
        }
80
 
81
        @Override
82
        public void limparEntidade() {
630 blopes 83
                consultarPosVenda();
623 blopes 84
        }
85
 
86
        public PosVendaDTO getPosVendaSelecionado() {
87
                return posVendaSelecionado;
88
        }
89
        public void setPosVendaSelecionado(PosVendaDTO posVendaSelecionado) {
90
                this.posVendaSelecionado = posVendaSelecionado;
91
        }
92
 
93
        /**************************************************/
94
 
95
        public TipoPeriodoConsulta[] getTiposPeriodoConsulta() {
96
                return TipoPeriodoConsulta.values();
97
        }
98
 
99
        /**************************************************/
100
 
101
        public void consultarPosVenda() {
102
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
103
                        public void execute() {
630 blopes 104
                                setEntidade(posVendaService.consultarPosVendaEmAndamento());
623 blopes 105
                        }
106
                });
107
        }
108
 
109
        public void selecionarPosVenda(PosVendaDTO posVenda/* , TipoPosVendaAtivacao tipoAtivacao */) {
110
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
111
                        public void execute() {
112
                                // CONSULTAR DETALHES BASEANDO-SE NO TIPO DE ATIVACAO
624 blopes 113
                                posVenda.getVendaDTO().setListaLancamentos(lancamentoService.consultarLancamentosDaVenda(posVenda.getVendaDTO().getSequencial()));
627 blopes 114
                                // CONSULTAR NPS PÓS-VENDA
630 blopes 115
                                posVenda.setNpsPosVendaAgradecimento(npsPosVendaService.consultarPorPosVendaEeTipo(posVenda.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor()));
623 blopes 116
                                setPosVendaSelecionado(posVenda);
117
                        }
118
                });
119
        }
120
 
630 blopes 121
        public void iniciarAtendimento() {
625 blopes 122
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
123
                        public void execute() {
630 blopes 124
                                posVendaService.iniciarAtendimento(getPosVendaSelecionado());
125
                                consultarPosVenda();
625 blopes 126
                                LancadorMensagem.lancarSucesso("PÓS-VENDA INICIADO COM SUCESSO");
127
                        }
128
                });
129
        }
130
 
623 blopes 131
}