Rev 264 | Rev 268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 264 | Rev 265 | ||
|---|---|---|---|
| Line 12... | Line 12... | ||
| 12 | import br.com.ec.core.util.VerificadorUtil; |
12 | import br.com.ec.core.util.VerificadorUtil; |
| 13 | import br.com.ec.domain.dto.FormaPagamentoDTO; |
13 | import br.com.ec.domain.dto.FormaPagamentoDTO; |
| 14 | import br.com.ec.domain.dto.LojaDTO; |
14 | import br.com.ec.domain.dto.LojaDTO; |
| 15 | import br.com.ec.domain.dto.consulta.ParametrosConsultaVendasDTO; |
15 | import br.com.ec.domain.dto.consulta.ParametrosConsultaVendasDTO; |
| 16 | import br.com.ec.domain.model.Venda; |
16 | import br.com.ec.domain.model.Venda; |
| - | 17 | import br.com.ec.domain.model.VendaFormaPagamento; |
|
| 17 | import br.com.ec.domain.shared.ConstantesSEC; |
18 | import br.com.ec.domain.shared.ConstantesSEC; |
| 18 | import br.com.ec.repository.SistemaAbstractRepository; |
19 | import br.com.ec.repository.SistemaAbstractRepository; |
| 19 | import br.com.ec.repository.VendaRepository; |
20 | import br.com.ec.repository.VendaRepository; |
| 20 | 21 | ||
| 21 | @Repository |
22 | @Repository |
| Line 73... | Line 74... | ||
| 73 | // parametrosConsulta.setIndicadorComissionado(null);
|
74 | // parametrosConsulta.setIndicadorComissionado(null);
|
| 74 | // parametrosConsulta.setTipoProduto(null);
|
75 | // parametrosConsulta.setTipoProduto(null);
|
| 75 | try { |
76 | try { |
| 76 | TypedQuery<Double> query = getEntityManager().createQuery(sql.toString(), Double.class); |
77 | TypedQuery<Double> query = getEntityManager().createQuery(sql.toString(), Double.class); |
| 77 | setarQueryParametrosConsulta(query, parametrosConsultaVendasDTO); |
78 | setarQueryParametrosConsulta(query, parametrosConsultaVendasDTO); |
| - | 79 | Double total = query.getSingleResult(); |
|
| - | 80 | if (VerificadorUtil.estaNulo(total)) { |
|
| - | 81 | return new Double(0.0); |
|
| - | 82 | }
|
|
| - | 83 | return total; |
|
| - | 84 | } catch(Exception ex) { |
|
| - | 85 | ex.printStackTrace(); |
|
| - | 86 | return null; |
|
| - | 87 | }
|
|
| - | 88 | }
|
|
| - | 89 | ||
| - | 90 | @Override |
|
| - | 91 | public Double obterValorDeMaquinetasPorPessoa(Long sequencialPessoaMaquineta, Date dataInicio, Date dataFim) { |
|
| - | 92 | StringBuilder sql = new StringBuilder(); |
|
| - | 93 | sql.append("SELECT SUM(p.valorPagamento) FROM VendaFormaPagamento p "); |
|
| - | 94 | sql.append("LEFT JOIN p.venda v "); |
|
| - | 95 | sql.append("WHERE p.formaPagamento.codigo IN :formasDePagamento "); |
|
| - | 96 | sql.append("AND v.maquineta.pessoa.sequencial = :sequencialPessoaMaquineta "); |
|
| - | 97 | sql.append("AND (v.dataVenda BETWEEN :dataInicial AND :dataFinal OR v.dataVenda = :dataInicial OR v.dataVenda = :dataFinal) "); |
|
| - | 98 | try { |
|
| - | 99 | TypedQuery<Double> query = getEntityManager().createQuery(sql.toString(), Double.class); |
|
| - | 100 | query.setParameter("formasDePagamento", FormaPagamentoDTO.codigosFormasDePagamentoViaCartao()); |
|
| - | 101 | query.setParameter("sequencialPessoaMaquineta", sequencialPessoaMaquineta); |
|
| - | 102 | query.setParameter("dataInicial", DataUtils.getDataComHorarioMinimo(dataInicio)); |
|
| - | 103 | query.setParameter("dataFinal", DataUtils.getDataComHorarioMaximo(dataFim)); |
|
| - | 104 | ||
| 78 | Double total = query.getSingleResult(); |
105 | Double total = query.getSingleResult(); |
| 79 | if (VerificadorUtil.estaNulo(total)) { |
106 | if (VerificadorUtil.estaNulo(total)) { |
| 80 | return new Double(0.0); |
107 | return new Double(0.0); |
| 81 | }
|
108 | }
|
| 82 | return total; |
109 | return total; |