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