Rev 624 | Rev 627 | 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; |
| 623 | blopes | 20 | import br.com.ec.domain.model.tipos.TipoPeriodoConsulta; |
| 624 | blopes | 21 | import br.com.ec.domain.service.LancamentoService; |
| 623 | blopes | 22 | import br.com.ec.domain.service.PosVendaService; |
| 23 | import br.com.ec.domain.service.TransferenciaService; |
||
| 24 | import br.com.ec.web.exception.VerificadorLancamentoException; |
||
| 25 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 26 | import br.com.ec.web.generic.AbstractBean; |
||
| 625 | blopes | 27 | import br.com.ec.web.message.LancadorMensagem; |
| 623 | blopes | 28 | |
| 29 | @Named |
||
| 30 | @Scope("view") |
||
| 31 | public class PosVendaBean extends AbstractBean<ComercialPosVendaDTO> implements Serializable { |
||
| 32 | |||
| 33 | private static final long serialVersionUID = 1L; |
||
| 34 | |||
| 35 | private PosVendaService posVendaService; |
||
| 624 | blopes | 36 | private LancamentoService lancamentoService; |
| 623 | blopes | 37 | |
| 38 | private PosVendaDTO posVendaSelecionado; |
||
| 39 | |||
| 625 | blopes | 40 | public static class NpsItem { |
| 41 | private final int nota; |
||
| 42 | private final String icone; |
||
| 43 | private final String estrelas; |
||
| 44 | |||
| 45 | public NpsItem(int nota, String icone, String estrelas) { |
||
| 46 | this.nota = nota; |
||
| 47 | this.icone = icone; |
||
| 48 | this.estrelas = estrelas; |
||
| 49 | } |
||
| 50 | |||
| 51 | public int getNota() { return nota; } |
||
| 52 | public String getIcone() { return icone; } |
||
| 53 | public String getEstrelas() { return estrelas; } |
||
| 54 | } |
||
| 55 | |||
| 623 | blopes | 56 | @Inject |
| 624 | blopes | 57 | public PosVendaBean(PosVendaService posVendaService, LancamentoService lancamentoService) { |
| 623 | blopes | 58 | this.posVendaService = posVendaService; |
| 624 | blopes | 59 | this.lancamentoService = lancamentoService; |
| 623 | blopes | 60 | } |
| 61 | |||
| 62 | @Override |
||
| 63 | public GenericService<ComercialPosVendaDTO> getService() { |
||
| 64 | return null; |
||
| 65 | } |
||
| 66 | |||
| 67 | @Override |
||
| 68 | public ComercialPosVendaDTO getId() { |
||
| 69 | return null; |
||
| 70 | } |
||
| 71 | |||
| 72 | @Override |
||
| 73 | public void preCarregamento() { |
||
| 74 | limparEntidade(); |
||
| 75 | } |
||
| 76 | |||
| 77 | @Override |
||
| 78 | public void limparEntidade() { |
||
| 79 | setEntidade(iniciarDados()); |
||
| 80 | } |
||
| 81 | |||
| 82 | public PosVendaDTO getPosVendaSelecionado() { |
||
| 83 | return posVendaSelecionado; |
||
| 84 | } |
||
| 85 | public void setPosVendaSelecionado(PosVendaDTO posVendaSelecionado) { |
||
| 86 | this.posVendaSelecionado = posVendaSelecionado; |
||
| 87 | } |
||
| 88 | |||
| 89 | /**************************************************/ |
||
| 90 | |||
| 91 | public TipoPeriodoConsulta[] getTiposPeriodoConsulta() { |
||
| 92 | return TipoPeriodoConsulta.values(); |
||
| 93 | } |
||
| 94 | |||
| 95 | /**************************************************/ |
||
| 96 | |||
| 97 | public void consultarPosVenda() { |
||
| 98 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 99 | public void execute() { |
||
| 100 | // iniciarDados(); |
||
| 101 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 102 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 103 | listaPosVendaDTO.addAll(posVendaService.consultarNaoFinalizadas()); |
||
| 104 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 105 | setEntidade(comercialDTO); |
||
| 106 | } |
||
| 107 | }); |
||
| 108 | } |
||
| 109 | |||
| 110 | public void selecionarPosVenda(PosVendaDTO posVenda/* , TipoPosVendaAtivacao tipoAtivacao */) { |
||
| 111 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 112 | public void execute() { |
||
| 113 | // CONSULTAR DETALHES BASEANDO-SE NO TIPO DE ATIVACAO |
||
| 624 | blopes | 114 | posVenda.getVendaDTO().setListaLancamentos(lancamentoService.consultarLancamentosDaVenda(posVenda.getVendaDTO().getSequencial())); |
| 623 | blopes | 115 | setPosVendaSelecionado(posVenda); |
| 116 | } |
||
| 117 | }); |
||
| 118 | } |
||
| 119 | |||
| 625 | blopes | 120 | public void iniciarSalvarPosVenda() { |
| 121 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 122 | public void execute() { |
||
| 123 | PosVenda posVendaParaAlterar = posVendaService.consultarPorId(new PosVenda(getPosVendaSelecionado().getSequencial())); |
||
| 124 | posVendaParaAlterar.setDataInicio(DataUtils.getDataAtual()); |
||
| 125 | posVendaParaAlterar.setObservacao(getPosVendaSelecionado().getObservacao()); |
||
| 126 | posVendaParaAlterar.setTipoFinalizacao(getPosVendaSelecionado().getTipoFinalizacao()); |
||
| 127 | posVendaService.alterar(posVendaParaAlterar); |
||
| 128 | LancadorMensagem.lancarSucesso("PÓS-VENDA INICIADO COM SUCESSO"); |
||
| 129 | } |
||
| 130 | }); |
||
| 131 | } |
||
| 132 | |||
| 623 | blopes | 133 | private ComercialPosVendaDTO iniciarDados() { |
| 134 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 135 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 136 | listaPosVendaDTO.addAll(posVendaService.consultarNaoFinalizadas()); |
||
| 137 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 138 | return comercialDTO; |
||
| 139 | |||
| 140 | /* |
||
| 141 | ComercialPosVendaDTO comercialDTO = new ComercialPosVendaDTO(); |
||
| 142 | List<PosVendaDTO> listaPosVendaDTO = new ArrayList<PosVendaDTO>(); |
||
| 143 | |||
| 144 | PosVendaDTO posVendaDTO = new PosVendaDTO(); |
||
| 145 | VendaDTO vendaDTO = new VendaDTO(); |
||
| 146 | vendaDTO.setSequencial(new Long(123456)); |
||
| 147 | Date data = DataUtils.acrescentarDias(new Date(), -5); |
||
| 148 | vendaDTO.setDataVenda(data); |
||
| 149 | ClienteDTO clienteDTO = new ClienteDTO(); |
||
| 150 | clienteDTO.setNome("BRUNO LOPES PEIXOTO"); |
||
| 151 | clienteDTO.setCpfCnpj("06256954459"); |
||
| 152 | clienteDTO.setContato("82996062514"); |
||
| 153 | vendaDTO.setCliente(clienteDTO); |
||
| 154 | posVendaDTO.setVendaDTO(vendaDTO); |
||
| 155 | posVendaDTO.setDataCadastro(data); |
||
| 156 | listaPosVendaDTO.add(posVendaDTO); |
||
| 157 | |||
| 158 | posVendaDTO = new PosVendaDTO(); |
||
| 159 | vendaDTO = new VendaDTO(); |
||
| 160 | vendaDTO.setSequencial(new Long(321654)); |
||
| 161 | vendaDTO.setDataVenda(new Date()); |
||
| 162 | clienteDTO = new ClienteDTO(); |
||
| 163 | clienteDTO.setNome("BÁRBARA ALVES"); |
||
| 164 | clienteDTO.setCpfCnpj("01234567890"); |
||
| 165 | clienteDTO.setContato("8299990000"); |
||
| 166 | vendaDTO.setCliente(clienteDTO); |
||
| 167 | posVendaDTO.setVendaDTO(vendaDTO); |
||
| 168 | posVendaDTO.setDataCadastro(new Date()); |
||
| 169 | listaPosVendaDTO.add(posVendaDTO); |
||
| 170 | |||
| 171 | comercialDTO.setListaPosVenda(listaPosVendaDTO); |
||
| 172 | |||
| 173 | return comercialDTO; |
||
| 174 | */ |
||
| 175 | } |
||
| 176 | |||
| 177 | } |