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 267 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | package br.com.ec.domain.service.impl; |
1 | package br.com.ec.domain.service.impl; |
| 2 | 2 | ||
| - | 3 | import java.util.ArrayList; |
|
| 3 | import java.util.Arrays; |
4 | import java.util.Arrays; |
| 4 | import java.util.Calendar; |
5 | import java.util.Calendar; |
| 5 | import java.util.Date; |
6 | import java.util.Date; |
| - | 7 | import java.util.List; |
|
| 6 | 8 | ||
| 7 | import org.primefaces.model.charts.ChartData; |
9 | import org.primefaces.model.charts.ChartData; |
| 8 | import org.primefaces.model.charts.axes.cartesian.CartesianScales; |
10 | import org.primefaces.model.charts.axes.cartesian.CartesianScales; |
| 9 | import org.primefaces.model.charts.axes.cartesian.linear.CartesianLinearAxes; |
11 | import org.primefaces.model.charts.axes.cartesian.linear.CartesianLinearAxes; |
| 10 | import org.primefaces.model.charts.axes.cartesian.linear.CartesianLinearTicks; |
12 | import org.primefaces.model.charts.axes.cartesian.linear.CartesianLinearTicks; |
| Line 12... | Line 14... | ||
| 12 | import org.primefaces.model.charts.bar.BarChartModel; |
14 | import org.primefaces.model.charts.bar.BarChartModel; |
| 13 | import org.primefaces.model.charts.bar.BarChartOptions; |
15 | import org.primefaces.model.charts.bar.BarChartOptions; |
| 14 | import org.primefaces.model.charts.optionconfig.legend.Legend; |
16 | import org.primefaces.model.charts.optionconfig.legend.Legend; |
| 15 | import org.primefaces.model.charts.optionconfig.legend.LegendLabel; |
17 | import org.primefaces.model.charts.optionconfig.legend.LegendLabel; |
| 16 | import org.primefaces.model.charts.optionconfig.title.Title; |
18 | import org.primefaces.model.charts.optionconfig.title.Title; |
| - | 19 | import org.primefaces.model.charts.pie.PieChartDataSet; |
|
| - | 20 | import org.primefaces.model.charts.pie.PieChartModel; |
|
| 17 | import org.springframework.beans.factory.annotation.Autowired; |
21 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | import org.springframework.stereotype.Service; |
22 | import org.springframework.stereotype.Service; |
| 19 | 23 | ||
| 20 | import br.com.ec.core.generic.AbstractService; |
24 | import br.com.ec.core.generic.AbstractService; |
| 21 | import br.com.ec.core.generic.GenericRepository; |
25 | import br.com.ec.core.generic.GenericRepository; |
| Line 24... | Line 28... | ||
| 24 | import br.com.ec.core.validador.Validador; |
28 | import br.com.ec.core.validador.Validador; |
| 25 | import br.com.ec.domain.dto.consulta.ParametrosConsultaVendasDTO; |
29 | import br.com.ec.domain.dto.consulta.ParametrosConsultaVendasDTO; |
| 26 | import br.com.ec.domain.dto.grafico.GraficoBarraDTO; |
30 | import br.com.ec.domain.dto.grafico.GraficoBarraDTO; |
| 27 | import br.com.ec.domain.dto.grafico.GraficoDTO; |
31 | import br.com.ec.domain.dto.grafico.GraficoDTO; |
| 28 | import br.com.ec.domain.dto.grafico.GraficoDadoDTO; |
32 | import br.com.ec.domain.dto.grafico.GraficoDadoDTO; |
| - | 33 | import br.com.ec.domain.dto.grafico.GraficoPizzaDTO; |
|
| 29 | import br.com.ec.domain.service.GraficoService; |
34 | import br.com.ec.domain.service.GraficoService; |
| 30 | import br.com.ec.domain.service.VendaService; |
35 | import br.com.ec.domain.service.VendaService; |
| 31 | 36 | ||
| 32 | @Service |
37 | @Service |
| 33 | public class GraficoServiceImpl extends AbstractService<GraficoDTO> implements GraficoService { |
38 | public class GraficoServiceImpl extends AbstractService<GraficoDTO> implements GraficoService { |
| Line 44... | Line 49... | ||
| 44 | protected GenericRepository<GraficoDTO> getRepository() { |
49 | protected GenericRepository<GraficoDTO> getRepository() { |
| 45 | return null; |
50 | return null; |
| 46 | }
|
51 | }
|
| 47 | 52 | ||
| 48 | @Override |
53 | @Override |
| 49 | public GraficoBarraDTO gerarGraficoVendas(ParametrosConsultaVendasDTO parametrosConsulta) { |
- | |
| - | 54 | public GraficoBarraDTO gerarGraficoVendas(ParametrosConsultaVendasDTO parametrosConsulta, ParametrosConsultaVendasDTO parametrosConsultaComparativo) { |
|
| 50 | GraficoBarraDTO graficoDTO = new GraficoBarraDTO(); |
55 | GraficoBarraDTO graficoDTO = new GraficoBarraDTO(); |
| 51 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorDia()) { |
56 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorDia()) { |
| 52 | graficoDTO.setDados(preencherDadosComPeriodoEhPorDia(parametrosConsulta)); |
- | |
| - | 57 | graficoDTO.setDados(preencherDadosComPeriodoEhPorDia(parametrosConsulta, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)")); |
|
| 53 | graficoDTO.setTitulo("VENDAS POR DIA"); |
58 | graficoDTO.setTitulo("VENDAS POR DIA"); |
| 54 | }
|
59 | }
|
| 55 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorMes()) { |
60 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorMes()) { |
| 56 | graficoDTO.setDados(preencherDadosComPeriodoEhPorMes(parametrosConsulta)); |
- | |
| - | 61 | graficoDTO.setDados(preencherDadosComPeriodoEhPorMes(parametrosConsulta, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)")); |
|
| 57 | graficoDTO.setTitulo("VENDAS POR MÊS"); |
62 | graficoDTO.setTitulo("VENDAS POR MÊS"); |
| 58 | }
|
63 | }
|
| 59 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorAno()) { |
64 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorAno()) { |
| 60 | graficoDTO.setDados(preencherDadosComPeriodoEhPorAno(parametrosConsulta)); |
- | |
| - | 65 | graficoDTO.setDados(preencherDadosComPeriodoEhPorAno(parametrosConsulta, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)")); |
|
| 61 | graficoDTO.setTitulo("VENDAS POR ANO"); |
66 | graficoDTO.setTitulo("VENDAS POR ANO"); |
| 62 | }
|
67 | }
|
| 63 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosSeisMeses() || |
68 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosSeisMeses() || |
| 64 | parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosDozeMeses()) { |
69 | parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosDozeMeses()) { |
| 65 | graficoDTO.setDados(preencherDadosComPeriodoEhUltimosSeisOuDozeMeses(parametrosConsulta)); |
- | |
| - | 70 | graficoDTO.setDados(preencherDadosComPeriodoEhUltimosSeisOuDozeMeses(parametrosConsulta, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)")); |
|
| 66 | graficoDTO.setTitulo("VENDAS PELOS ÚLTIMOS MESES"); |
71 | graficoDTO.setTitulo("VENDAS PELOS ÚLTIMOS MESES"); |
| 67 | /*
|
72 | /*
|
| 68 | if (VerificadorUtil.naoEstaNulo(parametrosRelatorioVendas.getVendedor())) {
|
73 | if (VerificadorUtil.naoEstaNulo(parametrosRelatorioVendas.getVendedor())) {
|
| 69 | consultarHistoricoPercentual(parametrosRelatorioVendas);
|
74 | consultarHistoricoPercentual(parametrosRelatorioVendas);
|
| 70 | }
|
75 | }
|
| Line 75... | Line 80... | ||
| 75 | barDataSet.setLabel(""); |
80 | barDataSet.setLabel(""); |
| 76 | barDataSet.setData(graficoDTO.getDados().getValores()); |
81 | barDataSet.setData(graficoDTO.getDados().getValores()); |
| 77 | barDataSet.setBackgroundColor(graficoDTO.getDados().getCores()); |
82 | barDataSet.setBackgroundColor(graficoDTO.getDados().getCores()); |
| 78 | barDataSet.setBorderColor(graficoDTO.getDados().getBordas()); |
83 | barDataSet.setBorderColor(graficoDTO.getDados().getBordas()); |
| 79 | barDataSet.setBorderWidth(1); |
84 | barDataSet.setBorderWidth(1); |
| - | 85 | ||
| 80 | ChartData dados = new ChartData(); |
86 | ChartData dados = new ChartData(); |
| 81 | dados.addChartDataSet(barDataSet); |
- | |
| 82 | dados.setLabels(graficoDTO.getDados().getMarcadores()); |
87 | dados.setLabels(graficoDTO.getDados().getMarcadores()); |
| - | 88 | ||
| - | 89 | if (VerificadorUtil.naoEstaNulo(parametrosConsultaComparativo)) { |
|
| - | 90 | parametrosConsultaComparativo.setFormasDePagamentoDTO(parametrosConsulta.getFormasDePagamentoDTO()); |
|
| - | 91 | parametrosConsultaComparativo.setLojasSelecionadasDTO(parametrosConsulta.getLojasSelecionadasDTO()); |
|
| - | 92 | parametrosConsultaComparativo.getParametrosPeriodoDTO().setTipoPeriodo(parametrosConsulta.getParametrosPeriodoDTO().getTipoPeriodo()); |
|
| - | 93 | GraficoBarraDTO graficoDTOComparativo = new GraficoBarraDTO(); |
|
| - | 94 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorDia()) { |
|
| - | 95 | graficoDTOComparativo.setDados(preencherDadosComPeriodoEhPorDia(parametrosConsultaComparativo, "rgba(255, 205, 86, 0.2)", "rgb(255, 205, 86)")); |
|
| - | 96 | graficoDTOComparativo.setTitulo("VENDAS POR DIA"); |
|
| - | 97 | }
|
|
| - | 98 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorMes()) { |
|
| - | 99 | graficoDTOComparativo.setDados(preencherDadosComPeriodoEhPorMes(parametrosConsultaComparativo, "rgba(255, 205, 86, 0.2)", "rgb(255, 205, 86)")); |
|
| - | 100 | graficoDTOComparativo.setTitulo("VENDAS POR MÊS"); |
|
| - | 101 | }
|
|
| - | 102 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorAno()) { |
|
| - | 103 | graficoDTOComparativo.setDados(preencherDadosComPeriodoEhPorAno(parametrosConsultaComparativo, "rgba(255, 205, 86, 0.2)", "rgb(255, 205, 86)")); |
|
| - | 104 | graficoDTOComparativo.setTitulo("VENDAS POR ANO"); |
|
| - | 105 | }
|
|
| - | 106 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosSeisMeses() || |
|
| - | 107 | parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosDozeMeses()) { |
|
| - | 108 | graficoDTOComparativo.setDados(preencherDadosComPeriodoEhUltimosSeisOuDozeMeses(parametrosConsultaComparativo, "rgba(255, 205, 86, 0.2)", "rgb(255, 205, 86)")); |
|
| - | 109 | graficoDTOComparativo.setTitulo("VENDAS PELOS ÚLTIMOS MESES"); |
|
| - | 110 | }
|
|
| - | 111 | BarChartDataSet barDataSetComparativo = new BarChartDataSet(); |
|
| - | 112 | barDataSetComparativo.setLabel("COMPARATIVO"); |
|
| - | 113 | barDataSetComparativo.setData(graficoDTOComparativo.getDados().getValores()); |
|
| - | 114 | barDataSetComparativo.setBackgroundColor(graficoDTOComparativo.getDados().getCores()); |
|
| - | 115 | barDataSetComparativo.setBorderColor(graficoDTOComparativo.getDados().getBordas()); |
|
| - | 116 | barDataSetComparativo.setBorderWidth(1); |
|
| - | 117 | ||
| - | 118 | dados.addChartDataSet(barDataSetComparativo); |
|
| - | 119 | }
|
|
| - | 120 | ||
| - | 121 | dados.addChartDataSet(barDataSet); |
|
| 83 | 122 | ||
| 84 | BarChartOptions options = new BarChartOptions(); |
123 | BarChartOptions options = new BarChartOptions(); |
| 85 | CartesianScales cScales = new CartesianScales(); |
124 | CartesianScales cScales = new CartesianScales(); |
| 86 | CartesianLinearAxes linearAxes = new CartesianLinearAxes(); |
125 | CartesianLinearAxes linearAxes = new CartesianLinearAxes(); |
| 87 | linearAxes.setOffset(true); |
126 | linearAxes.setOffset(true); |
| Line 117... | Line 156... | ||
| 117 | 156 | ||
| 118 | graficoDTO.setGraficoBarra(graficoBarra); |
157 | graficoDTO.setGraficoBarra(graficoBarra); |
| 119 | return graficoDTO; |
158 | return graficoDTO; |
| 120 | }
|
159 | }
|
| 121 | 160 | ||
| 122 | private GraficoDadoDTO preencherDadosComPeriodoEhPorDia(ParametrosConsultaVendasDTO parametrosConsulta) { |
- | |
| - | 161 | private GraficoDadoDTO preencherDadosComPeriodoEhPorDia(ParametrosConsultaVendasDTO parametrosConsulta, String cor, String corBorda) { |
|
| 123 | GraficoDadoDTO dados = new GraficoDadoDTO(); |
162 | GraficoDadoDTO dados = new GraficoDadoDTO(); |
| 124 | Calendar dataInicial = DataUtils.obterCalendario(DataUtils.obterData(1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getMes())-1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()))); |
163 | Calendar dataInicial = DataUtils.obterCalendario(DataUtils.obterData(1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getMes())-1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()))); |
| 125 | int qntMaximaDias = dataInicial.getActualMaximum(Calendar.DAY_OF_MONTH); |
164 | int qntMaximaDias = dataInicial.getActualMaximum(Calendar.DAY_OF_MONTH); |
| 126 | for (int dia = 1; dia <= qntMaximaDias; dia++) { |
165 | for (int dia = 1; dia <= qntMaximaDias; dia++) { |
| 127 | Double valorAcumulado = new Double(0.0); |
166 | Double valorAcumulado = new Double(0.0); |
| 128 | Date data = DataUtils.obterData(dia, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getMes())-1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno())); |
167 | Date data = DataUtils.obterData(dia, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getMes())-1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno())); |
| 129 | parametrosConsulta.getParametrosPeriodoDTO().setDataInicial(data); |
168 | parametrosConsulta.getParametrosPeriodoDTO().setDataInicial(data); |
| 130 | parametrosConsulta.getParametrosPeriodoDTO().setDataFinal(data); |
169 | parametrosConsulta.getParametrosPeriodoDTO().setDataFinal(data); |
| 131 | valorAcumulado = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento(parametrosConsulta, Arrays.asList(parametrosConsulta.getFormasDePagamentoDTO())); |
170 | valorAcumulado = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento(parametrosConsulta, Arrays.asList(parametrosConsulta.getFormasDePagamentoDTO())); |
| 132 | dados.adicionarDados(valorAcumulado, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)", "" + dia); |
- | |
| - | 171 | dados.adicionarDados(valorAcumulado, cor, corBorda, "" + dia); |
|
| 133 | }
|
172 | }
|
| 134 | return dados; |
173 | return dados; |
| 135 | }
|
174 | }
|
| 136 | 175 | ||
| 137 | private GraficoDadoDTO preencherDadosComPeriodoEhPorMes(ParametrosConsultaVendasDTO parametrosConsulta) { |
- | |
| - | 176 | private GraficoDadoDTO preencherDadosComPeriodoEhPorMes(ParametrosConsultaVendasDTO parametrosConsulta, String cor, String corBorda) { |
|
| 138 | GraficoDadoDTO dados = new GraficoDadoDTO(); |
177 | GraficoDadoDTO dados = new GraficoDadoDTO(); |
| 139 | for (int mes = 1; mes <= 12; mes++) { |
178 | for (int mes = 1; mes <= 12; mes++) { |
| 140 | Double valorAcumulado = new Double(0.0); |
179 | Double valorAcumulado = new Double(0.0); |
| 141 | Calendar dataInicial = DataUtils.obterCalendario(DataUtils.obterData(1, new Integer(mes)-1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()))); |
180 | Calendar dataInicial = DataUtils.obterCalendario(DataUtils.obterData(1, new Integer(mes)-1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()))); |
| 142 | int qntMaximaDias = dataInicial.getActualMaximum(Calendar.DAY_OF_MONTH); |
181 | int qntMaximaDias = dataInicial.getActualMaximum(Calendar.DAY_OF_MONTH); |
| 143 | Calendar dataFinal = DataUtils.obterCalendario(DataUtils.obterData(qntMaximaDias, new Integer(mes)-1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()))); |
182 | Calendar dataFinal = DataUtils.obterCalendario(DataUtils.obterData(qntMaximaDias, new Integer(mes)-1, new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()))); |
| 144 | parametrosConsulta.getParametrosPeriodoDTO().setDataInicial(dataInicial.getTime()); |
183 | parametrosConsulta.getParametrosPeriodoDTO().setDataInicial(dataInicial.getTime()); |
| 145 | parametrosConsulta.getParametrosPeriodoDTO().setDataFinal(dataFinal.getTime()); |
184 | parametrosConsulta.getParametrosPeriodoDTO().setDataFinal(dataFinal.getTime()); |
| 146 | valorAcumulado = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento( |
185 | valorAcumulado = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento( |
| 147 | parametrosConsulta, Arrays.asList(parametrosConsulta.getFormasDePagamentoDTO())); |
186 | parametrosConsulta, Arrays.asList(parametrosConsulta.getFormasDePagamentoDTO())); |
| 148 | dados.adicionarDados(valorAcumulado, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)", "" + mes); |
- | |
| - | 187 | dados.adicionarDados(valorAcumulado, cor, corBorda, "" + mes); |
|
| 149 | }
|
188 | }
|
| 150 | return dados; |
189 | return dados; |
| 151 | }
|
190 | }
|
| 152 | 191 | ||
| 153 | private GraficoDadoDTO preencherDadosComPeriodoEhPorAno(ParametrosConsultaVendasDTO parametrosConsulta) { |
- | |
| - | 192 | private GraficoDadoDTO preencherDadosComPeriodoEhPorAno(ParametrosConsultaVendasDTO parametrosConsulta, String cor, String corBorda) { |
|
| 154 | GraficoDadoDTO dados = new GraficoDadoDTO(); |
193 | GraficoDadoDTO dados = new GraficoDadoDTO(); |
| 155 | Integer anoInicial = new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()) - 10; |
194 | Integer anoInicial = new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()) - 10; |
| 156 | for (int ano = anoInicial; ano <= new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()); ano++) { |
195 | for (int ano = anoInicial; ano <= new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()); ano++) { |
| 157 | Double valorAcumulado = new Double(0.0); |
196 | Double valorAcumulado = new Double(0.0); |
| 158 | Calendar dataInicial = DataUtils.obterCalendario(DataUtils.obterData(1, 0, new Integer(ano))); |
197 | Calendar dataInicial = DataUtils.obterCalendario(DataUtils.obterData(1, 0, new Integer(ano))); |
| 159 | Calendar dataFinal = DataUtils.obterCalendario(DataUtils.obterData(31, 13, new Integer(ano))); |
198 | Calendar dataFinal = DataUtils.obterCalendario(DataUtils.obterData(31, 13, new Integer(ano))); |
| 160 | parametrosConsulta.getParametrosPeriodoDTO().setDataInicial(dataInicial.getTime()); |
199 | parametrosConsulta.getParametrosPeriodoDTO().setDataInicial(dataInicial.getTime()); |
| 161 | parametrosConsulta.getParametrosPeriodoDTO().setDataFinal(dataFinal.getTime()); |
200 | parametrosConsulta.getParametrosPeriodoDTO().setDataFinal(dataFinal.getTime()); |
| 162 | valorAcumulado = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento(parametrosConsulta, Arrays.asList(parametrosConsulta.getFormasDePagamentoDTO())); |
201 | valorAcumulado = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento(parametrosConsulta, Arrays.asList(parametrosConsulta.getFormasDePagamentoDTO())); |
| 163 | dados.adicionarDados(valorAcumulado, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)", "" + ano); |
- | |
| - | 202 | dados.adicionarDados(valorAcumulado, cor, corBorda, "" + ano); |
|
| 164 | }
|
203 | }
|
| 165 | return dados; |
204 | return dados; |
| 166 | }
|
205 | }
|
| 167 | 206 | ||
| 168 | private GraficoDadoDTO preencherDadosComPeriodoEhUltimosSeisOuDozeMeses(ParametrosConsultaVendasDTO parametrosConsulta) { |
- | |
| - | 207 | private GraficoDadoDTO preencherDadosComPeriodoEhUltimosSeisOuDozeMeses(ParametrosConsultaVendasDTO parametrosConsulta, String cor, String corBorda) { |
|
| 169 | GraficoDadoDTO dados = new GraficoDadoDTO(); |
208 | GraficoDadoDTO dados = new GraficoDadoDTO(); |
| 170 | Integer mesAtual = new Integer(parametrosConsulta.getParametrosPeriodoDTO().getMes()); |
209 | Integer mesAtual = new Integer(parametrosConsulta.getParametrosPeriodoDTO().getMes()); |
| 171 | Integer anoAtual = new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()); |
210 | Integer anoAtual = new Integer(parametrosConsulta.getParametrosPeriodoDTO().getAno()); |
| 172 | Integer quantidadeMesesAnteriores = 0; |
211 | Integer quantidadeMesesAnteriores = 0; |
| 173 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosSeisMeses()) { |
212 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosSeisMeses()) { |
| Line 193... | Line 232... | ||
| 193 | int qntMaximaDias = dataInicial.getActualMaximum(Calendar.DAY_OF_MONTH); |
232 | int qntMaximaDias = dataInicial.getActualMaximum(Calendar.DAY_OF_MONTH); |
| 194 | parametrosConsulta.getParametrosPeriodoDTO().setDataFinal(DataUtils.obterCalendario(DataUtils.obterData(qntMaximaDias, mesAtual - 1, anoAtual)).getTime()); |
233 | parametrosConsulta.getParametrosPeriodoDTO().setDataFinal(DataUtils.obterCalendario(DataUtils.obterData(qntMaximaDias, mesAtual - 1, anoAtual)).getTime()); |
| 195 | valorAcumulado = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento(parametrosConsulta, Arrays.asList(parametrosConsulta.getFormasDePagamentoDTO())); |
234 | valorAcumulado = vendaService.obterValorTotalBrutoDeVendasPorLojaEePeriodoEeFormasDePagamento(parametrosConsulta, Arrays.asList(parametrosConsulta.getFormasDePagamentoDTO())); |
| 196 | String descricaoLinha = mesAtual.toString() + "/" + anoAtual; |
235 | String descricaoLinha = mesAtual.toString() + "/" + anoAtual; |
| 197 | mesAtual++;
|
236 | mesAtual++;
|
| 198 | dados.adicionarDados(valorAcumulado, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)", "" + descricaoLinha); |
- | |
| - | 237 | dados.adicionarDados(valorAcumulado, cor, corBorda, "" + descricaoLinha); |
|
| 199 | }
|
238 | }
|
| 200 | return dados; |
239 | return dados; |
| 201 | }
|
240 | }
|
| 202 | 241 | ||
| - | 242 | @Override |
|
| - | 243 | public GraficoPizzaDTO gerarGraficoVendasPorFormasDePagamento(ParametrosConsultaVendasDTO parametrosConsulta) { |
|
| - | 244 | GraficoBarraDTO graficoDTO = new GraficoBarraDTO(); |
|
| - | 245 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorDia()) { |
|
| - | 246 | graficoDTO.setDados(preencherDadosComPeriodoEhPorDia(parametrosConsulta, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)")); |
|
| - | 247 | graficoDTO.setTitulo("VENDAS POR DIA"); |
|
| - | 248 | }
|
|
| - | 249 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorMes()) { |
|
| - | 250 | graficoDTO.setDados(preencherDadosComPeriodoEhPorMes(parametrosConsulta, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)")); |
|
| - | 251 | graficoDTO.setTitulo("VENDAS POR MÊS"); |
|
| - | 252 | }
|
|
| - | 253 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhPorAno()) { |
|
| - | 254 | graficoDTO.setDados(preencherDadosComPeriodoEhPorAno(parametrosConsulta, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)")); |
|
| - | 255 | graficoDTO.setTitulo("VENDAS POR ANO"); |
|
| - | 256 | }
|
|
| - | 257 | if (parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosSeisMeses() || |
|
| - | 258 | parametrosConsulta.getParametrosPeriodoDTO().tipoPeriodoEhUltimosDozeMeses()) { |
|
| - | 259 | graficoDTO.setDados(preencherDadosComPeriodoEhUltimosSeisOuDozeMeses(parametrosConsulta, "rgba(75, 192, 192, 0.2)", "rgb(75, 192, 192)")); |
|
| - | 260 | graficoDTO.setTitulo("VENDAS PELOS ÚLTIMOS MESES"); |
|
| - | 261 | }
|
|
| - | 262 | ||
| - | 263 | PieChartModel graficoFormasPagamento = new PieChartModel(); |
|
| - | 264 | ChartData dataFP = new ChartData(); |
|
| - | 265 | PieChartDataSet dataSetFP = new PieChartDataSet(); |
|
| - | 266 | List<Number> valuesFP = new ArrayList<>(); |
|
| - | 267 | valuesFP.add(300); |
|
| - | 268 | valuesFP.add(50); |
|
| - | 269 | valuesFP.add(100); |
|
| - | 270 | dataSetFP.setData(valuesFP); |
|
| - | 271 | List<String> bgColorsFP = new ArrayList<>(); |
|
| - | 272 | bgColorsFP.add("rgb(255, 99, 132)"); |
|
| - | 273 | bgColorsFP.add("rgb(54, 162, 235)"); |
|
| - | 274 | bgColorsFP.add("rgb(255, 205, 86)"); |
|
| - | 275 | dataSetFP.setBackgroundColor(bgColorsFP); |
|
| - | 276 | dataFP.addChartDataSet(dataSetFP); |
|
| - | 277 | List<String> labelsFP = new ArrayList<>(); |
|
| - | 278 | labelsFP.add("DINHEIRO"); |
|
| - | 279 | labelsFP.add("DÉBITO"); |
|
| - | 280 | labelsFP.add("CARTÃO À VISTA"); |
|
| - | 281 | labelsFP.add("PARCELADO"); |
|
| - | 282 | dataFP.setLabels(labelsFP); |
|
| - | 283 | graficoFormasPagamento.setData(dataFP); |
|
| - | 284 | ||
| - | 285 | GraficoPizzaDTO grafico = new GraficoPizzaDTO(); |
|
| - | 286 | grafico.setGraficoPizza(graficoFormasPagamento); |
|
| - | 287 | ||
| - | 288 | return grafico; |
|
| - | 289 | }
|
|
| 203 | }
|
290 | }
|