Subversion Repositories Integrator Subversion

Rev

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