Rev 629 | Rev 631 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 629 | Rev 630 | ||
|---|---|---|---|
| Line 3... | Line 3... | ||
| 3 | import java.util.List; |
3 | import java.util.List; |
| 4 | 4 | ||
| 5 | import org.springframework.beans.factory.annotation.Autowired; |
5 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | import org.springframework.stereotype.Service; |
6 | import org.springframework.stereotype.Service; |
| 7 | 7 | ||
| - | 8 | import br.com.ec.core.exception.NegocioException; |
|
| 8 | import br.com.ec.core.generic.AbstractService; |
9 | import br.com.ec.core.generic.AbstractService; |
| 9 | import br.com.ec.core.generic.GenericRepository; |
10 | import br.com.ec.core.generic.GenericRepository; |
| - | 11 | import br.com.ec.core.util.DataUtils; |
|
| - | 12 | import br.com.ec.core.util.VerificadorUtil; |
|
| 10 | import br.com.ec.core.validador.Validador; |
13 | import br.com.ec.core.validador.Validador; |
| - | 14 | import br.com.ec.domain.dto.ComercialPosVendaDTO; |
|
| - | 15 | import br.com.ec.domain.dto.NpsPosVendaDTO; |
|
| 11 | import br.com.ec.domain.dto.PosVendaDTO; |
16 | import br.com.ec.domain.dto.PosVendaDTO; |
| 12 | import br.com.ec.domain.model.PosVenda; |
17 | import br.com.ec.domain.model.PosVenda; |
| - | 18 | import br.com.ec.domain.model.tipos.TipoNpsPosVenda; |
|
| - | 19 | import br.com.ec.domain.service.NpsPosVendaService; |
|
| 13 | import br.com.ec.domain.service.PosVendaService; |
20 | import br.com.ec.domain.service.PosVendaService; |
| 14 | import br.com.ec.repository.PosVendaRepository; |
21 | import br.com.ec.repository.PosVendaRepository; |
| 15 | 22 | ||
| 16 | @Service |
23 | @Service |
| 17 | public class PosVendaServiceImpl extends AbstractService<PosVenda> implements PosVendaService { |
24 | public class PosVendaServiceImpl extends AbstractService<PosVenda> implements PosVendaService { |
| 18 | - | ||
| - | 25 | ||
| 19 | private PosVendaRepository posVendaRepository; |
26 | private PosVendaRepository posVendaRepository; |
| - | 27 | private NpsPosVendaService npsPosVendaService; |
|
| 20 | 28 | ||
| 21 | @Autowired |
29 | @Autowired |
| 22 | public PosVendaServiceImpl(Validador validador, PosVendaRepository posVendaRepository) { |
- | |
| - | 30 | public PosVendaServiceImpl(Validador validador, PosVendaRepository posVendaRepository, NpsPosVendaService npsPosVendaService) { |
|
| 23 | super(validador); |
31 | super(validador); |
| 24 | this.posVendaRepository = posVendaRepository; |
32 | this.posVendaRepository = posVendaRepository; |
| - | 33 | this.npsPosVendaService = npsPosVendaService; |
|
| 25 | }
|
34 | }
|
| 26 | 35 | ||
| 27 | @Override |
36 | @Override |
| 28 | protected GenericRepository<PosVenda> getRepository() { |
37 | protected GenericRepository<PosVenda> getRepository() { |
| 29 | return posVendaRepository; |
38 | return posVendaRepository; |
| 30 | }
|
39 | }
|
| 31 | 40 | ||
| 32 | @Override |
41 | @Override |
| 33 | public List<PosVendaDTO> consultarNaoFinalizadas() { |
- | |
| 34 | // List<PosVendaDTO> listaPosVendaNaoFinalizadas = posVendaRepository.consultarNaoFinalizadas();
|
- | |
| 35 | return posVendaRepository.consultarNaoFinalizadas(); |
- | |
| - | 42 | public ComercialPosVendaDTO consultarPosVendaEmAndamento() { |
|
| - | 43 | ComercialPosVendaDTO comercialPosVendaDTO = new ComercialPosVendaDTO(); |
|
| - | 44 | List<PosVendaDTO> listaPosVendaNaoFinalizadas = posVendaRepository.consultarNaoFinalizadas(); |
|
| - | 45 | for (PosVendaDTO posVendaNaoFinalizada : listaPosVendaNaoFinalizadas) { |
|
| - | 46 | NpsPosVendaDTO npsPosVendaAgradecimento = npsPosVendaService.consultarPorPosVendaEeTipo(posVendaNaoFinalizada.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor()); |
|
| - | 47 | if (VerificadorUtil.naoEstaNulo(npsPosVendaAgradecimento)) { |
|
| - | 48 | if (VerificadorUtil.estaNulo(npsPosVendaAgradecimento.getDataFinalizacao())) { |
|
| - | 49 | posVendaNaoFinalizada.setNpsPosVendaAgradecimento(npsPosVendaAgradecimento); |
|
| - | 50 | comercialPosVendaDTO.getListaPosVendaAgradecimento().add(posVendaNaoFinalizada); |
|
| - | 51 | }
|
|
| - | 52 | }
|
|
| - | 53 | posVendaNaoFinalizada.setNpsPosVendaAgradecimento(npsPosVendaService.consultarPorPosVendaEeTipo(posVendaNaoFinalizada.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor())); |
|
| - | 54 | }
|
|
| - | 55 | comercialPosVendaDTO.setListaEmAndamento(listaPosVendaNaoFinalizadas); |
|
| - | 56 | return comercialPosVendaDTO; |
|
| - | 57 | }
|
|
| - | 58 | ||
| - | 59 | @Override |
|
| - | 60 | public void iniciarAtendimento(PosVendaDTO posVendaDTO) { |
|
| - | 61 | try { |
|
| - | 62 | PosVenda posVendaParaAlterar = this.consultarPorId(new PosVenda(posVendaDTO.getSequencial())); |
|
| - | 63 | posVendaParaAlterar.setDataInicio(DataUtils.getDataAtual()); |
|
| - | 64 | posVendaParaAlterar.setObservacao(posVendaDTO.getObservacao()); |
|
| - | 65 | posVendaParaAlterar.setTipoFinalizacao(posVendaDTO.getTipoFinalizacao()); |
|
| - | 66 | // NpsPosVendaDTO npsPosVendaDTO = npsPosVendaService.consultarPorPosVendaEeTipo(posVendaDTO.getSequencial(), TipoNpsPosVenda.ATENDIMENTO_A.getValor());
|
|
| - | 67 | // NpsPosVenda npsPosVenda = npsPosVendaService.consultarPorId(new NpsPosVenda(npsPosVendaDTO.getSequencial()));
|
|
| - | 68 | // npsPosVendaService.alterar(npsPosVenda);
|
|
| - | 69 | this.alterar(posVendaParaAlterar); |
|
| - | 70 | } catch (Exception e) { |
|
| - | 71 | throw new NegocioException(e.getMessage()); |
|
| - | 72 | }
|
|
| 36 | }
|
73 | }
|
| 37 | 74 | ||
| 38 | }
|
75 | }
|