Rev 296 | Rev 561 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 296 | Rev 450 | ||
|---|---|---|---|
| Line 8... | Line 8... | ||
| 8 | 8 | ||
| 9 | import org.springframework.stereotype.Repository; |
9 | import org.springframework.stereotype.Repository; |
| 10 | 10 | ||
| 11 | import br.com.ec.core.util.DataUtils; |
11 | import br.com.ec.core.util.DataUtils; |
| 12 | import br.com.ec.core.util.VerificadorUtil; |
12 | import br.com.ec.core.util.VerificadorUtil; |
| - | 13 | import br.com.ec.domain.dto.AuditoriaVendaDTO; |
|
| 13 | import br.com.ec.domain.dto.FormaPagamentoDTO; |
14 | import br.com.ec.domain.dto.FormaPagamentoDTO; |
| 14 | import br.com.ec.domain.dto.LojaDTO; |
15 | import br.com.ec.domain.dto.LojaDTO; |
| 15 | import br.com.ec.domain.dto.consulta.ParametrosConsultaVendasDTO; |
16 | import br.com.ec.domain.dto.consulta.ParametrosConsultaVendasDTO; |
| 16 | import br.com.ec.domain.model.Venda; |
17 | import br.com.ec.domain.model.Venda; |
| 17 | import br.com.ec.domain.shared.ConstantesSEC; |
18 | import br.com.ec.domain.shared.ConstantesSEC; |
| Line 603... | Line 604... | ||
| 603 | Double total = query.getSingleResult(); |
604 | Double total = query.getSingleResult(); |
| 604 | if (VerificadorUtil.estaNulo(total)) { |
605 | if (VerificadorUtil.estaNulo(total)) { |
| 605 | return new Double(0.0); |
606 | return new Double(0.0); |
| 606 | }
|
607 | }
|
| 607 | return total; |
608 | return total; |
| - | 609 | } catch(Exception ex) { |
|
| - | 610 | ex.printStackTrace(); |
|
| - | 611 | return null; |
|
| - | 612 | }
|
|
| - | 613 | }
|
|
| - | 614 | ||
| - | 615 | @Override |
|
| - | 616 | public List<AuditoriaVendaDTO> consultarAuditoriaVenda(Date dataSelecionada, Long sequencialLojaSelecionada) { |
|
| - | 617 | StringBuilder sql = new StringBuilder(); |
|
| - | 618 | // (Long sequencialVenda, Long sequencialLoja, Date dataHoraVenda, Double valorTotal, Double valorTrocaCancelamento)
|
|
| - | 619 | sql.append("SELECT new br.com.ec.domain.dto.AuditoriaVendaDTO("); |
|
| - | 620 | sql.append("v.sequencial, v.loja.sequencial, v.dataVenda, SUM(vfp.valorPagamento), "); |
|
| - | 621 | sql.append("(SELECT SUM(vfpcupom.valorPagamento) FROM VendaFormaPagamento vfpcupom WHERE "); |
|
| - | 622 | sql.append("vfpcupom.venda.sequencial = v.sequencial AND vfpcupom.formaPagamento.codigo = 16)"); |
|
| - | 623 | sql.append(") FROM Venda v "); |
|
| - | 624 | sql.append("LEFT JOIN v.listaVendaFormaPagamentos vfp ON vfp.formaPagamento.codigo <> 16 "); |
|
| - | 625 | sql.append("WHERE v.loja.sequencial = :sequencialLojaSelecionada "); |
|
| - | 626 | sql.append("AND v.dataVenda >= :dataInicial AND v.dataVenda <= :dataFinal "); |
|
| - | 627 | sql.append("GROUP BY (v.sequencial) "); |
|
| - | 628 | sql.append("ORDER BY (v.dataVenda) "); |
|
| - | 629 | try { |
|
| - | 630 | TypedQuery<AuditoriaVendaDTO> query = getEntityManager().createQuery(sql.toString(), AuditoriaVendaDTO.class); |
|
| - | 631 | query.setParameter("dataInicial", DataUtils.getDataComHorarioMinimo(dataSelecionada)); |
|
| - | 632 | query.setParameter("dataFinal", DataUtils.getDataComHorarioMaximo(dataSelecionada)); |
|
| - | 633 | query.setParameter("sequencialLojaSelecionada", sequencialLojaSelecionada); |
|
| - | 634 | return query.getResultList(); |
|
| 608 | } catch(Exception ex) { |
635 | } catch(Exception ex) { |
| 609 | ex.printStackTrace(); |
636 | ex.printStackTrace(); |
| 610 | return null; |
637 | return null; |
| 611 | }
|
638 | }
|
| 612 | }
|
639 | }
|