Subversion Repositories Integrator Subversion

Rev

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

Rev Author Line No. Line
229 espaco 1
package br.com.ec.domain.service.impl;
2
 
3
import java.util.ArrayList;
4
import java.util.List;
5
 
6
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.stereotype.Service;
8
 
9
import br.com.ec.core.generic.AbstractService;
10
import br.com.ec.core.generic.GenericRepository;
11
import br.com.ec.core.util.DataUtils;
230 espaco 12
import br.com.ec.core.util.VerificadorUtil;
229 espaco 13
import br.com.ec.core.validador.Validador;
14
import br.com.ec.domain.dto.LojaDTO;
15
import br.com.ec.domain.dto.TempoRealDTO;
16
import br.com.ec.domain.dto.TempoRealLojaDTO;
296 espaco 17
import br.com.ec.domain.dto.consulta.ParametrosConsultaVendasDTO;
253 espaco 18
import br.com.ec.domain.service.AberturaLojaService;
230 espaco 19
import br.com.ec.domain.service.AvaliacaoLojaService;
229 espaco 20
import br.com.ec.domain.service.LojaService;
21
import br.com.ec.domain.service.TempoRealService;
22
import br.com.ec.domain.service.VendaService;
230 espaco 23
import br.com.ec.domain.shared.Ordenador;
24
import br.com.ec.domain.shared.OrdenadorImpl;
229 espaco 25
 
26
@Service
27
public class TempoRealServiceImpl extends AbstractService<TempoRealDTO> implements TempoRealService {
28
 
29
        private LojaService lojaService;
30
        private VendaService vendaService;
230 espaco 31
        private AvaliacaoLojaService avaliacaoLojaService;
253 espaco 32
        private AberturaLojaService aberturaLojaService;
229 espaco 33
 
230 espaco 34
        private Ordenador ordenador;
229 espaco 35
 
36
        @Autowired
253 espaco 37
        public TempoRealServiceImpl(Validador validador, LojaService lojaService, VendaService vendaService, AvaliacaoLojaService avaliacaoLojaService,
38
                        AberturaLojaService aberturaLojaService) {
229 espaco 39
                super(validador);
230 espaco 40
                this.ordenador = new OrdenadorImpl();
229 espaco 41
                this.lojaService = lojaService;
42
                this.vendaService = vendaService;
230 espaco 43
                this.avaliacaoLojaService = avaliacaoLojaService;
253 espaco 44
                this.aberturaLojaService = aberturaLojaService;
229 espaco 45
        }
46
 
47
        @Override
48
        protected GenericRepository<TempoRealDTO> getRepository() {
49
                return null;
50
        }
51
 
52
        @Override
53
        public TempoRealDTO consultarTempoReal() {
54
                TempoRealDTO tempoReal = new TempoRealDTO();
55
                List<LojaDTO> lojasAtivasDTO = lojaService.consultarLojasAtivas();
56
                List<TempoRealLojaDTO> lojasTempoRealDTO = new ArrayList<TempoRealLojaDTO>();
57
                for (LojaDTO lojaAtivaDTO : lojasAtivasDTO) {
58
                        TempoRealLojaDTO tempoRealLojaDTO = new TempoRealLojaDTO();
59
                        tempoRealLojaDTO.setLojaDTO(lojaAtivaDTO);
60
 
296 espaco 61
                        ParametrosConsultaVendasDTO parametrosConsultaVendasDTO = new ParametrosConsultaVendasDTO(lojaAtivaDTO.getSequencial(), DataUtils.getDataAtual(), DataUtils.getDataAtual());
62
                        tempoRealLojaDTO.setValorVendasNoDia(vendaService.obterValorTotalBrutoDeVendas(parametrosConsultaVendasDTO));
63
                        tempoRealLojaDTO.setQuantidadeVendasNoDia(vendaService.obterQuantidadeDeVendasPorLojaEePeriodo(lojaAtivaDTO.getSequencial(), DataUtils.getPrimeiroDiaDoMesAtual(), DataUtils.getUltimoDiaDoMesAtual()));
64
                        tempoRealLojaDTO.setValorVendasNoMes(vendaService.obterValorTotalBrutoDeVendas(new ParametrosConsultaVendasDTO(lojaAtivaDTO.getSequencial(), DataUtils.getPrimeiroDiaDoMesAtual(), DataUtils.getUltimoDiaDoMesAtual())));
259 espaco 65
                        tempoRealLojaDTO.setValorMetaMensal(avaliacaoLojaService.consultarValorMetaMensalLojaPelaData(lojaAtivaDTO.getSequencial(), DataUtils.getDataAtual()));
253 espaco 66
                        tempoRealLojaDTO.setPercentualRealizadoMetaMensal(VerificadorUtil.naoEstaNulo(tempoRealLojaDTO.getValorMetaMensal())? tempoRealLojaDTO.getValorVendasNoMes()/tempoRealLojaDTO.getValorMetaMensal() : 0.0);
67
 
259 espaco 68
                        tempoRealLojaDTO.setLojaAberta(aberturaLojaService.verificarLojaAberta(DataUtils.getDataAtual(), lojaAtivaDTO.getSequencial()));
69
                        tempoRealLojaDTO.setLojaComVendasNovas(vendaService.obterQuantidadeDeVendasNovasPorLojaEePeriodo(lojaAtivaDTO.getSequencial(), DataUtils.getDataAtual(), DataUtils.getDataAtual()) > 0);
229 espaco 70
                        /******/
71
                        lojasTempoRealDTO.add(tempoRealLojaDTO);
72
                }
253 espaco 73
                tempoReal.setIndicadorVendasNovas(vendaService.obterQuantidadeDeVendasNovasPorLojaEePeriodo(null, DataUtils.getDataAtual(), DataUtils.getDataAtual()) > 0);
230 espaco 74
                tempoReal.preencherDados(new ArrayList<TempoRealLojaDTO>(ordenador.ordenar(lojasTempoRealDTO)));
229 espaco 75
                return tempoReal;
76
        }
77
 
78
}
79
 
80
/*
81
@Override
82
public AcompanhamentoDTO consultarConsolidacaoDoDia() {
83
        AcompanhamentoDTO consolidado = new AcompanhamentoDTO();
84
        List<ConsolidadoVendasLojaDTO> listaLojaDoDiaDTO = new ArrayList<ConsolidadoVendasLojaDTO>();
85
        List<Loja> lojas = lojaService.listarLojasAtivas();
86
 
87
        for (Loja loja : lojas) {
88
                ConsolidadoVendasLojaDTO consolidadoVendasLoja = new ConsolidadoVendasLojaDTO();
89
                consolidadoVendasLoja.setLoja(loja);
90
                Venda venda = new Venda(loja, null);
91
                Integer quantidadeVendas = vendaService.obterQuantidadeDeVendasPorLojaEePeriodo(venda, DataUtils.getDataAtual(), DataUtils.getDataAtual());
92
                consolidado.adicionarQuantidadeVendas(quantidadeVendas);
93
                consolidadoVendasLoja.setQuantidadeTotalVendas(quantidadeVendas);
94
 
95
                Double valorVendas = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(loja, DataUtils.getDataAtual(), DataUtils.getDataAtual());
96
                ParametrosConsultaVendasDTO parametrosConsultaVendas = new ParametrosConsultaVendasDTO();
97
                parametrosConsultaVendas.setLoja(loja);
98
                parametrosConsultaVendas.setDataInicial(DataUtils.getDataAtual());
99
                parametrosConsultaVendas.setDataFinal(DataUtils.getDataAtual());
100
                valorVendas = valorVendas - vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoServicos(parametrosConsultaVendas);
101
                consolidado.adicionarValorVendas(valorVendas);
102
                consolidadoVendasLoja.setValorTotalVendas(valorVendas);
103
 
104
                parametrosConsultaVendas.setDataInicial(DataUtils.getDataComHorarioMinimo(DataUtils.getPrimeiroDiaDoMesAtual()));
105
        parametrosConsultaVendas.setDataFinal(DataUtils.getDataComHorarioMaximo(DataUtils.acrescentarDias(DataUtils.getDataAtual(), -1)));
106
                Double totalVendasAnterioresDoMesAtual = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(parametrosConsultaVendas);
107
                totalVendasAnterioresDoMesAtual = totalVendasAnterioresDoMesAtual - vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoServicos(parametrosConsultaVendas);
108
                consolidadoVendasLoja.setValorTotalVendasAnterioresDoMesAtual(totalVendasAnterioresDoMesAtual);
109
 
110
                Double valorMetaMensalLoja = consultarMetaMensal(loja);
111
                consolidadoVendasLoja.setValorMetaMensal(valorMetaMensalLoja);
112
                consolidado.adicionarValorMeta(valorMetaMensalLoja);
113
 
114
                consolidadoVendasLoja.setIndicadorLojaAberta(aberturaLojaService.consultarAberturaLoja(DataUtils.getDataAtual(), loja) != null);
115
                venda.setTipoSituacao(TipoSituacaoVenda.NOVO.getValor());
116
                consolidadoVendasLoja.setIndicadorVendasNovas(vendaService.obterQuantidadeDeVendasPorLojaEePeriodo(venda, DataUtils.getDataAtual(), DataUtils.getDataAtual()) > 0);
117
 
118
                listaLojaDoDiaDTO.add(consolidadoVendasLoja);
119
        }
120
 
121
        ConsolidadoVendasLojaDTO consolidadoVendasLojaAssistencia = new ConsolidadoVendasLojaDTO();
122
        Loja lojaAssistencia = new Loja();
123
        lojaAssistencia.setDescricao("ASSISTÊNCIA");
124
        consolidadoVendasLojaAssistencia.setLoja(lojaAssistencia);
125
        ParametrosConsultaVendasDTO parametrosConsultaVendas = new ParametrosConsultaVendasDTO();
126
        parametrosConsultaVendas.setDataInicial(DataUtils.getDataAtual());
127
        parametrosConsultaVendas.setDataFinal(DataUtils.getDataAtual());
128
        consolidadoVendasLojaAssistencia.setValorTotalVendas(vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoServicos(parametrosConsultaVendas));
129
        consolidadoVendasLojaAssistencia.setIndicadorLojaAberta(true);
130
        listaLojaDoDiaDTO.add(consolidadoVendasLojaAssistencia);
131
 
132
        consolidado.setListaLojaDoDiaDTO(new ArrayList<ConsolidadoVendasLojaDTO>(ordenador.ordenar(listaLojaDoDiaDTO)));
133
        consolidado.setValorTotalVendasMes(vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(null, DataUtils.getPrimeiroDiaDoMesAtual(), DataUtils.getUltimoDiaDoMesAtual()));
134
        consolidado.setQuantidadeTotalPagamentos(pagamentoService.quantidadePagamentosEmAberto(null));
135
        consolidado.setQuantidadeTotalPendencias(pendenciaService.quantidadePendenciasNaoFinalizadas(null));
136
 
137
        Date diaDoMesPassado = DataUtils.acrescentarMeses(DataUtils.getDataAtual(), -1);
138
        consolidado.setValorTotalVendasDoDiaMesPassado(vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(null, diaDoMesPassado, diaDoMesPassado));
139
        consolidado.setValorTotalVendasMesPassado(vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(null, DataUtils.getPrimeiroDiaDoMesAnterior(), diaDoMesPassado));
140
 
141
        return consolidado;
142
}
143
 
144
@Override
145
public ConsolidadoGestaoDTO consultarConsolidadoGestaoDTO() {
146
        ConsolidadoGestaoDTO consolidado = new ConsolidadoGestaoDTO();
147
        consolidado.setQuantidadeTotalVendas(vendaService.obterQuantidadeDeVendasPorLojaEePeriodo(null, DataUtils.getDataAtual(), DataUtils.getDataAtual()));
148
        consolidado.setValorTotalVendasMes(vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(null, DataUtils.getPrimeiroDiaDoMesAtual(), DataUtils.getUltimoDiaDoMesAtual()));
149
        consolidado.setQuantidadeTotalEstoque(produtoService.quantidadeTotalEstoque(null));
150
        consolidado.setValorTotalEstoque(produtoService.valorTotalEstoque(null, null));
151
        return consolidado;
152
}
153
 
154
@Override
155
public LineChartModel consultarGrafico(Date primeiroMes, Date segundoMes) {
156
        LineChartModel graficoAcumulado = new LineChartModel();
157
        String mesAtual = "" + (DataUtils.obterCalendario(primeiroMes).get(Calendar.MONTH)+1);
158
        String anoAtual = "" + DataUtils.obterCalendario(primeiroMes).get(Calendar.YEAR);
159
        String anoAnterior = "" + DataUtils.obterCalendario(segundoMes).get(Calendar.YEAR);
160
        String mesAnterior = "" + (DataUtils.obterCalendario(segundoMes).get(Calendar.MONTH)+1);
161
        if (mesAnterior.equals("0")) {
162
                mesAnterior = "12";
163
                anoAnterior = "" + (DataUtils.obterCalendario(DataUtils.getDataAtual()).get(Calendar.YEAR)-1);
164
        }
165
        if (mesAtual.length()==1) {
166
                mesAtual = "0" + mesAtual;
167
        }
168
        if (mesAnterior.length()==1) {
169
                mesAnterior = "0" + mesAnterior;
170
        }
171
 
172
        GraficoAcumuladoDTO graficoAtual = vendaService.consultarGrafico(mesAtual, anoAtual);
173
        LineChartSeries series1 = preencherLinhaAcumulando(graficoAtual, mesAtual, anoAtual);
174
    series1.setLabel("ATUAL");
175
 
176
    GraficoAcumuladoDTO graficoAnterior = vendaService.consultarGrafico(mesAnterior, anoAnterior);
177
    LineChartSeries series2 = preencherLinhaAcumulando(graficoAnterior, mesAtual, anoAtual);
178
    series2.setLabel("ANTERIOR");
179
 
180
    graficoAcumulado.addSeries(series1);
181
    graficoAcumulado.addSeries(series2);
182
 
183
    graficoAcumulado.setTitle("");
184
    graficoAcumulado.setZoom(true);
185
    graficoAcumulado.setShowPointLabels(true);
186
    graficoAcumulado.getAxis(AxisType.Y).setLabel("VALORES R$");
187
    DateAxis axis = new DateAxis("DATAS");
188
    axis.setTickAngle(-50);
189
    axis.setMin(anoAtual + "-" + mesAtual + "-" + "01");
190
    axis.setMax(anoAtual + "-" + mesAtual + "-" + "31");
191
    axis.setTickFormat("%b %#d, 20%y");
192
    graficoAcumulado.getAxes().put(AxisType.X, axis);
193
    return graficoAcumulado;
194
}
195
 
196
private LineChartSeries preencherLinhaAcumulando(GraficoAcumuladoDTO graficoLinha, String mes, String ano) {
197
        LineChartSeries linha = new LineChartSeries();
198
        Double valorAcumulado = new Double(0.0);
199
        valorAcumulado = valorAcumulado + graficoLinha.getDIA_01();
200
    linha.set(ano + "-" + mes + "-" + "01", valorAcumulado);
201
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_02();
202
    linha.set(ano + "-" + mes + "-" + "02", valorAcumulado);
203
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_03();
204
    linha.set(ano + "-" + mes + "-" + "03", valorAcumulado);
205
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_04();
206
    linha.set(ano + "-" + mes + "-" + "04", valorAcumulado);
207
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_05();
208
    linha.set(ano + "-" + mes + "-" + "05", valorAcumulado);
209
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_06();
210
    linha.set(ano + "-" + mes + "-" + "06", valorAcumulado);
211
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_07();
212
    linha.set(ano + "-" + mes + "-" + "07", valorAcumulado);
213
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_08();
214
    linha.set(ano + "-" + mes + "-" + "08", valorAcumulado);
215
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_09();
216
    linha.set(ano + "-" + mes + "-" + "09", valorAcumulado);
217
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_10();
218
    linha.set(ano + "-" + mes + "-" + "10", valorAcumulado);
219
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_11();
220
    linha.set(ano + "-" + mes + "-" + "11", valorAcumulado);
221
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_12();
222
    linha.set(ano + "-" + mes + "-" + "12", valorAcumulado);
223
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_13();
224
    linha.set(ano + "-" + mes + "-" + "13", valorAcumulado);
225
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_14();
226
    linha.set(ano + "-" + mes + "-" + "14", valorAcumulado);
227
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_15();
228
    linha.set(ano + "-" + mes + "-" + "15", valorAcumulado);
229
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_16();
230
    linha.set(ano + "-" + mes + "-" + "16", valorAcumulado);
231
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_17();
232
    linha.set(ano + "-" + mes + "-" + "17", valorAcumulado);
233
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_18();
234
    linha.set(ano + "-" + mes + "-" + "18", valorAcumulado);
235
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_19();
236
    linha.set(ano + "-" + mes + "-" + "19", valorAcumulado);
237
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_20();
238
    linha.set(ano + "-" + mes + "-" + "20", valorAcumulado);
239
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_21();
240
    linha.set(ano + "-" + mes + "-" + "21", valorAcumulado);
241
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_22();
242
    linha.set(ano + "-" + mes + "-" + "22", valorAcumulado);
243
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_23();
244
    linha.set(ano + "-" + mes + "-" + "23", valorAcumulado);
245
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_24();
246
    linha.set(ano + "-" + mes + "-" + "24", valorAcumulado);
247
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_25();
248
    linha.set(ano + "-" + mes + "-" + "25", valorAcumulado);
249
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_26();
250
    linha.set(ano + "-" + mes + "-" + "26", valorAcumulado);
251
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_27();
252
    linha.set(ano + "-" + mes + "-" + "27", valorAcumulado);
253
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_28();
254
    linha.set(ano + "-" + mes + "-" + "28", valorAcumulado);
255
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_29();
256
    linha.set(ano + "-" + mes + "-" + "29", valorAcumulado);
257
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_30();
258
    linha.set(ano + "-" + mes + "-" + "30", valorAcumulado);
259
    valorAcumulado = valorAcumulado + graficoLinha.getDIA_31();
260
    linha.set(ano + "-" + mes + "-" + "31", valorAcumulado);
261
    return linha;
262
}
263
 
264
@Override
265
public ProvisaoCaixaDTO consultarGraficoCaixa(Date dataInicial, Date dataFinal) {
266
        LineChartModel graficoAcumulado = new LineChartModel();
267
        String mes = "" + (DataUtils.obterCalendario(dataInicial).get(Calendar.MONTH)+1);
268
        String ano = "" + DataUtils.obterCalendario(dataInicial).get(Calendar.YEAR);
269
        if (mes.length()==1) {
270
                mes = "0" + mes;
271
        }
272
 
273
        Double caixa = contaBancariaService.consultarSaldo(null);
274
        List<DetalhamentoCaixaDTO> graficoAtual = fluxoDeCaixaService.consultarGraficoCaixa(caixa, dataInicial, dataFinal);
275
        LineChartSeries series1 = preencherLinha(graficoAtual, mes, ano);
276
    series1.setLabel("ATUAL");
277
 
278
    graficoAcumulado.addSeries(series1);
279
 
280
    graficoAcumulado.setTitle("");
281
    graficoAcumulado.setZoom(true);
282
    graficoAcumulado.setShowPointLabels(true);
283
    graficoAcumulado.getAxis(AxisType.Y).setLabel("VALORES R$");
284
    DateAxis axis = new DateAxis("DATAS");
285
    axis.setTickAngle(-50);
286
    axis.setMin(DataUtils.converterDataParaStringNoFormato(dataInicial, "yyyy - MM - dd"));
287
    axis.setMax(DataUtils.converterDataParaStringNoFormato(dataFinal, "yyyy - MM - dd"));
288
//    axis.setMin(ano + "-" + mes + "-" + "01");
289
//    axis.setMax(ano + "-" + mes + "-" + graficoAtual.size());
290
    axis.setTickFormat("%b %#d");
291
    graficoAcumulado.getAxes().put(AxisType.X, axis);
292
 
293
    ProvisaoCaixaDTO provisao = new ProvisaoCaixaDTO();
294
    provisao.setGrafico(graficoAcumulado);
295
    provisao.setDetalhamentos(graficoAtual);
296
    return provisao;
297
}
298
 
299
private LineChartSeries preencherLinha(List<DetalhamentoCaixaDTO> detalhamentos, String mes, String ano) {
300
        LineChartSeries linha = new LineChartSeries();
301
//      Integer indice = 1;
302
//      String dia = "";
303
        for (DetalhamentoCaixaDTO detalhamento : detalhamentos) {
304
//              if (indice < 10) {
305
//                      dia = "0" + indice;
306
//              } else {
307
//                      dia = "" + indice;
308
//              }
309
//              indice++;
310
//              linha.set(ano + "-" + mes + "-" + dia, detalhamento.getSaldo());
311
                linha.set(detalhamento.dataFormatada(), detalhamento.getSaldo());
312
        }
313
    return linha;
314
}
315
 
316
@Override
317
public FluxoDeCaixaDTO consultarFluxoDeCaixa(FluxoDeCaixaDTO fluxoDeCaixa) {
318
        return fluxoDeCaixaService.consultarFluxoDeCaixa(fluxoDeCaixa);
319
}
320
 
321
@Override
322
public List<FluxoDeCaixaCategoriaDTO> consultarFluxoDeCaixaPorCategoria(FluxoDeCaixaDTO fluxoDeCaixa, String tipoCategoria) {
323
        return fluxoDeCaixaService.consultarFluxoDeCaixaPorCategoria(fluxoDeCaixa, tipoCategoria);
324
}
325
 
326
@Override
327
public ReceitaDTO consultarReceita(ReceitaDTO receita) {
328
        ParametrosConsultaVendasDTO parametrosConsultaVendas = new ParametrosConsultaVendasDTO();
329
        parametrosConsultaVendas.setDataInicial(receita.getDataInicial());
330
        parametrosConsultaVendas.setDataFinal(receita.getDataFinal());
331
        parametrosConsultaVendas.setLoja(receita.getLoja());
332
        parametrosConsultaVendas.setVendedor(receita.getVendedor());
333
        parametrosConsultaVendas.setIndicacao(receita.getIndicacao());
334
 
335
        receita.setValorTotalBruto(vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(parametrosConsultaVendas));
336
        receita.setValorTotalLiquido(vendaService.obterValorTotalLiquidoDeVendasPorLojaEePeriodo(parametrosConsultaVendas));
337
        receita.setValorTotalBrutoPorFormasDePagamento(vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento(parametrosConsultaVendas, verificarSelecoesFormasPagamento(receita)));
338
        receita.setQuantidadeTotalEstoque(produtoService.quantidadeTotalEstoque(receita.getLoja()));
339
        receita.setValorTotalEstoque(produtoService.valorTotalEstoque(receita.getLoja(), null));
340
        receita.setQuantidadeProdutosVendidos(vendaService.obterQuantidadeProdutosVendidosPorLojaEePeriodoNaoVivo(parametrosConsultaVendas));
341
        receita.setValorProdutosUtilizados(vendaService.obterValorProdutosUtilizadosEmVendasPorLojaEePeriodo(parametrosConsultaVendas));
342
        receita.setProcessado(true);
343
        return receita;
344
}
345
 
346
private List<FormaPagamento> verificarSelecoesFormasPagamento(ReceitaDTO receita) {
347
        List<FormaPagamento> formas = new ArrayList<FormaPagamento>();
348
        List<FormaPagamento> formasSelecionadas = Arrays.asList(receita.getFormasDePagamento());
349
        if (VerificadorUtil.naoEstaNulo(receita.getFormasDePagamento())) {
350
                for (FormaPagamento forma : formasSelecionadas) {
351
                        if (VerificadorUtil.naoEstaNulo(forma)) {
352
                                formas.add(forma);
353
                        }
354
                }
355
        }
356
        return formas;
357
}
358
 
359
@Override
360
public DreDTO consultarDRE(DreDTO dre) {
361
        ParametrosConsultaVendasDTO parametrosConsultaVendas = new ParametrosConsultaVendasDTO();
362
        parametrosConsultaVendas.setDataInicial(dre.getDataInicial());
363
        parametrosConsultaVendas.setDataFinal(dre.getDataFinal());
364
        parametrosConsultaVendas.setLojas(dre.getLojasSelecionadas());
365
 
366
        List<DreItemDTO> itens = new ArrayList<DreItemDTO>();
367
        DreItemDTO itemDRE = new DreItemDTO("RECEITA OPERACIONAL BRUTA"); //VENDAS DE PRODUTOS, MERCADORIAS E SERVIÇOS
368
        Double valor = new Double(0.0);
369
        vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodo(parametrosConsultaVendas);
370
 
371
        itemDRE.setValor(valor);
372
        itens.add(itemDRE);
373
        dre.setItens(itens);
374
        return dre;
375
}
376
 
377
private Double consultarMetaMensal(Loja loja) {
378
        return avaliacaoLojaService.consultarValorMetaMensalLojaPelaData(loja.getSequencial(), DataUtils.getDataAtual());
379
}
380
 
381
*/