Rev 229 | Rev 253 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 229 | Rev 230 | ||
|---|---|---|---|
| Line 7... | Line 7... | ||
| 7 | import org.springframework.stereotype.Service; |
7 | import org.springframework.stereotype.Service; |
| 8 | 8 | ||
| 9 | import br.com.ec.core.generic.AbstractService; |
9 | import br.com.ec.core.generic.AbstractService; |
| 10 | import br.com.ec.core.generic.GenericRepository; |
10 | import br.com.ec.core.generic.GenericRepository; |
| 11 | import br.com.ec.core.util.DataUtils; |
11 | import br.com.ec.core.util.DataUtils; |
| - | 12 | import br.com.ec.core.util.VerificadorUtil; |
|
| 12 | import br.com.ec.core.validador.Validador; |
13 | import br.com.ec.core.validador.Validador; |
| 13 | import br.com.ec.domain.dto.LojaDTO; |
14 | import br.com.ec.domain.dto.LojaDTO; |
| 14 | import br.com.ec.domain.dto.TempoRealDTO; |
15 | import br.com.ec.domain.dto.TempoRealDTO; |
| 15 | import br.com.ec.domain.dto.TempoRealLojaDTO; |
16 | import br.com.ec.domain.dto.TempoRealLojaDTO; |
| - | 17 | import br.com.ec.domain.service.AvaliacaoLojaService; |
|
| 16 | import br.com.ec.domain.service.LojaService; |
18 | import br.com.ec.domain.service.LojaService; |
| 17 | import br.com.ec.domain.service.TempoRealService; |
19 | import br.com.ec.domain.service.TempoRealService; |
| 18 | import br.com.ec.domain.service.VendaService; |
20 | import br.com.ec.domain.service.VendaService; |
| - | 21 | import br.com.ec.domain.shared.Ordenador; |
|
| - | 22 | import br.com.ec.domain.shared.OrdenadorImpl; |
|
| 19 | import br.com.ec.repository.DashboardRepository; |
23 | import br.com.ec.repository.DashboardRepository; |
| 20 | 24 | ||
| 21 | @Service |
25 | @Service |
| 22 | public class TempoRealServiceImpl extends AbstractService<TempoRealDTO> implements TempoRealService { |
26 | public class TempoRealServiceImpl extends AbstractService<TempoRealDTO> implements TempoRealService { |
| 23 | 27 | ||
| 24 | private LojaService lojaService; |
28 | private LojaService lojaService; |
| 25 | private VendaService vendaService; |
29 | private VendaService vendaService; |
| - | 30 | private AvaliacaoLojaService avaliacaoLojaService; |
|
| 26 | 31 | ||
| 27 | // private DashboardRepository dashboardRepository;
|
- | |
| - | 32 | private Ordenador ordenador; |
|
| 28 | 33 | ||
| 29 | @Autowired |
34 | @Autowired |
| 30 | public TempoRealServiceImpl(Validador validador, LojaService lojaService, VendaService vendaService, DashboardRepository dashboardRepository) { |
- | |
| - | 35 | public TempoRealServiceImpl(Validador validador, LojaService lojaService, VendaService vendaService, AvaliacaoLojaService avaliacaoLojaService) { |
|
| 31 | super(validador); |
36 | super(validador); |
| - | 37 | this.ordenador = new OrdenadorImpl(); |
|
| 32 | this.lojaService = lojaService; |
38 | this.lojaService = lojaService; |
| 33 | this.vendaService = vendaService; |
39 | this.vendaService = vendaService; |
| - | 40 | this.avaliacaoLojaService = avaliacaoLojaService; |
|
| 34 | }
|
41 | }
|
| 35 | 42 | ||
| 36 | @Override |
43 | @Override |
| 37 | protected GenericRepository<TempoRealDTO> getRepository() { |
44 | protected GenericRepository<TempoRealDTO> getRepository() { |
| 38 | return null; |
45 | return null; |
| Line 45... | Line 52... | ||
| 45 | List<TempoRealLojaDTO> lojasTempoRealDTO = new ArrayList<TempoRealLojaDTO>(); |
52 | List<TempoRealLojaDTO> lojasTempoRealDTO = new ArrayList<TempoRealLojaDTO>(); |
| 46 | for (LojaDTO lojaAtivaDTO : lojasAtivasDTO) { |
53 | for (LojaDTO lojaAtivaDTO : lojasAtivasDTO) { |
| 47 | TempoRealLojaDTO tempoRealLojaDTO = new TempoRealLojaDTO(); |
54 | TempoRealLojaDTO tempoRealLojaDTO = new TempoRealLojaDTO(); |
| 48 | tempoRealLojaDTO.setLojaDTO(lojaAtivaDTO); |
55 | tempoRealLojaDTO.setLojaDTO(lojaAtivaDTO); |
| 49 | 56 | ||
| 50 | tempoRealLojaDTO.setQuantidadeTotalVendas(vendaService.obterQuantidadeDeVendasPorLojaEePeriodo(lojaAtivaDTO.getSequencialLoja(), DataUtils.getDataAtual(), DataUtils.getDataAtual())); |
- | |
| 51 | - | ||
| - | 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 | ||
| 52 | /******/
|
63 | /******/
|
| 53 | lojasTempoRealDTO.add(tempoRealLojaDTO); |
64 | lojasTempoRealDTO.add(tempoRealLojaDTO); |
| 54 | }
|
65 | }
|
| 55 | tempoReal.setListaTempoRealLojaDTO(lojasTempoRealDTO); |
- | |
| - | 66 | tempoReal.preencherDados(new ArrayList<TempoRealLojaDTO>(ordenador.ordenar(lojasTempoRealDTO))); |
|
| 56 | return tempoReal; |
67 | return tempoReal; |
| 57 | }
|
68 | }
|
| 58 | 69 | ||
| 59 | }
|
70 | }
|
| 60 | 71 | ||